2 Copyright (C) The Weather Channel, Inc. 2002.
3 Copyright (C) 2004 Nicolai Haehnle.
6 The Weather Channel (TM) funded Tungsten Graphics to develop the
7 initial release of the Radeon 8500 driver under the XFree86 license.
8 This notice must be preserved.
10 Permission is hereby granted, free of charge, to any person obtaining
11 a copy of this software and associated documentation files (the
12 "Software"), to deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sublicense, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
18 The above copyright notice and this permission notice (including the
19 next paragraph) shall be included in all copies or substantial
20 portions of the Software.
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
26 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 **************************************************************************/
35 * \author Nicolai Haehnle <prefect_@gmx.net>
45 #include "simple_list.h"
47 #include "api_arrayelt.h"
48 #include "swrast/swrast.h"
49 #include "swrast_setup/swrast_setup.h"
50 #include "shader/prog_parameter.h"
51 #include "shader/prog_statevars.h"
54 #include "texformat.h"
56 #include "radeon_ioctl.h"
57 #include "radeon_state.h"
58 #include "r300_context.h"
59 #include "r300_ioctl.h"
60 #include "r300_state.h"
62 #include "r300_emit.h"
63 #include "r300_fragprog.h"
66 #include "drirenderbuffer.h"
68 extern int future_hw_tcl_on
;
69 extern void _tnl_UpdateFixedFunctionProgram(GLcontext
* ctx
);
71 static void r300BlendColor(GLcontext
* ctx
, const GLfloat cf
[4])
74 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
76 R300_STATECHANGE(rmesa
, blend_color
);
78 CLAMPED_FLOAT_TO_UBYTE(color
[0], cf
[0]);
79 CLAMPED_FLOAT_TO_UBYTE(color
[1], cf
[1]);
80 CLAMPED_FLOAT_TO_UBYTE(color
[2], cf
[2]);
81 CLAMPED_FLOAT_TO_UBYTE(color
[3], cf
[3]);
83 rmesa
->hw
.blend_color
.cmd
[1] = PACK_COLOR_8888(color
[3], color
[0],
85 rmesa
->hw
.blend_color
.cmd
[2] = 0;
86 rmesa
->hw
.blend_color
.cmd
[3] = 0;
90 * Calculate the hardware blend factor setting. This same function is used
91 * for source and destination of both alpha and RGB.
94 * The hardware register value for the specified blend factor. This value
95 * will need to be shifted into the correct position for either source or
99 * Since the two cases where source and destination are handled differently
100 * are essentially error cases, they should never happen. Determine if these
101 * cases can be removed.
103 static int blend_factor(GLenum factor
, GLboolean is_src
)
107 return R300_BLEND_GL_ZERO
;
110 return R300_BLEND_GL_ONE
;
113 return R300_BLEND_GL_DST_COLOR
;
115 case GL_ONE_MINUS_DST_COLOR
:
116 return R300_BLEND_GL_ONE_MINUS_DST_COLOR
;
119 return R300_BLEND_GL_SRC_COLOR
;
121 case GL_ONE_MINUS_SRC_COLOR
:
122 return R300_BLEND_GL_ONE_MINUS_SRC_COLOR
;
125 return R300_BLEND_GL_SRC_ALPHA
;
127 case GL_ONE_MINUS_SRC_ALPHA
:
128 return R300_BLEND_GL_ONE_MINUS_SRC_ALPHA
;
131 return R300_BLEND_GL_DST_ALPHA
;
133 case GL_ONE_MINUS_DST_ALPHA
:
134 return R300_BLEND_GL_ONE_MINUS_DST_ALPHA
;
136 case GL_SRC_ALPHA_SATURATE
:
137 return (is_src
) ? R300_BLEND_GL_SRC_ALPHA_SATURATE
:
140 case GL_CONSTANT_COLOR
:
141 return R300_BLEND_GL_CONST_COLOR
;
143 case GL_ONE_MINUS_CONSTANT_COLOR
:
144 return R300_BLEND_GL_ONE_MINUS_CONST_COLOR
;
146 case GL_CONSTANT_ALPHA
:
147 return R300_BLEND_GL_CONST_ALPHA
;
149 case GL_ONE_MINUS_CONSTANT_ALPHA
:
150 return R300_BLEND_GL_ONE_MINUS_CONST_ALPHA
;
153 fprintf(stderr
, "unknown blend factor %x\n", factor
);
154 return (is_src
) ? R300_BLEND_GL_ONE
: R300_BLEND_GL_ZERO
;
160 * Sets both the blend equation and the blend function.
161 * This is done in a single
162 * function because some blend equations (i.e., \c GL_MIN and \c GL_MAX)
163 * change the interpretation of the blend function.
164 * Also, make sure that blend function and blend equation are set to their
165 * default value if color blending is not enabled, since at least blend
166 * equations GL_MIN and GL_FUNC_REVERSE_SUBTRACT will cause wrong results
167 * otherwise for unknown reasons.
170 /* helper function */
171 static void r300SetBlendCntl(r300ContextPtr r300
, int func
, int eqn
,
172 int cbits
, int funcA
, int eqnA
)
174 GLuint new_ablend
, new_cblend
;
178 "eqnA=%08x funcA=%08x eqn=%08x func=%08x cbits=%08x\n",
179 eqnA
, funcA
, eqn
, func
, cbits
);
181 new_ablend
= eqnA
| funcA
;
182 new_cblend
= eqn
| func
;
184 /* Some blend factor combinations don't seem to work when the
185 * BLEND_NO_SEPARATE bit is set.
187 * Especially problematic candidates are the ONE_MINUS_* flags,
188 * but I can't see a real pattern.
191 if (new_ablend
== new_cblend
) {
192 new_cblend
|= R300_BLEND_NO_SEPARATE
;
197 if ((new_ablend
!= r300
->hw
.bld
.cmd
[R300_BLD_ABLEND
]) ||
198 (new_cblend
!= r300
->hw
.bld
.cmd
[R300_BLD_CBLEND
])) {
199 R300_STATECHANGE(r300
, bld
);
200 r300
->hw
.bld
.cmd
[R300_BLD_ABLEND
] = new_ablend
;
201 r300
->hw
.bld
.cmd
[R300_BLD_CBLEND
] = new_cblend
;
205 static void r300SetBlendState(GLcontext
* ctx
)
207 r300ContextPtr r300
= R300_CONTEXT(ctx
);
208 int func
= (R300_BLEND_GL_ONE
<< R300_SRC_BLEND_SHIFT
) |
209 (R300_BLEND_GL_ZERO
<< R300_DST_BLEND_SHIFT
);
210 int eqn
= R300_COMB_FCN_ADD_CLAMP
;
211 int funcA
= (R300_BLEND_GL_ONE
<< R300_SRC_BLEND_SHIFT
) |
212 (R300_BLEND_GL_ZERO
<< R300_DST_BLEND_SHIFT
);
213 int eqnA
= R300_COMB_FCN_ADD_CLAMP
;
215 if (RGBA_LOGICOP_ENABLED(ctx
) || !ctx
->Color
.BlendEnabled
) {
216 r300SetBlendCntl(r300
, func
, eqn
, 0, func
, eqn
);
221 (blend_factor(ctx
->Color
.BlendSrcRGB
, GL_TRUE
) <<
222 R300_SRC_BLEND_SHIFT
) | (blend_factor(ctx
->Color
.BlendDstRGB
,
224 R300_DST_BLEND_SHIFT
);
226 switch (ctx
->Color
.BlendEquationRGB
) {
228 eqn
= R300_COMB_FCN_ADD_CLAMP
;
231 case GL_FUNC_SUBTRACT
:
232 eqn
= R300_COMB_FCN_SUB_CLAMP
;
235 case GL_FUNC_REVERSE_SUBTRACT
:
236 eqn
= R300_COMB_FCN_RSUB_CLAMP
;
240 eqn
= R300_COMB_FCN_MIN
;
241 func
= (R300_BLEND_GL_ONE
<< R300_SRC_BLEND_SHIFT
) |
242 (R300_BLEND_GL_ONE
<< R300_DST_BLEND_SHIFT
);
246 eqn
= R300_COMB_FCN_MAX
;
247 func
= (R300_BLEND_GL_ONE
<< R300_SRC_BLEND_SHIFT
) |
248 (R300_BLEND_GL_ONE
<< R300_DST_BLEND_SHIFT
);
253 "[%s:%u] Invalid RGB blend equation (0x%04x).\n",
254 __FUNCTION__
, __LINE__
, ctx
->Color
.BlendEquationRGB
);
259 (blend_factor(ctx
->Color
.BlendSrcA
, GL_TRUE
) <<
260 R300_SRC_BLEND_SHIFT
) | (blend_factor(ctx
->Color
.BlendDstA
,
262 R300_DST_BLEND_SHIFT
);
264 switch (ctx
->Color
.BlendEquationA
) {
266 eqnA
= R300_COMB_FCN_ADD_CLAMP
;
269 case GL_FUNC_SUBTRACT
:
270 eqnA
= R300_COMB_FCN_SUB_CLAMP
;
273 case GL_FUNC_REVERSE_SUBTRACT
:
274 eqnA
= R300_COMB_FCN_RSUB_CLAMP
;
278 eqnA
= R300_COMB_FCN_MIN
;
279 funcA
= (R300_BLEND_GL_ONE
<< R300_SRC_BLEND_SHIFT
) |
280 (R300_BLEND_GL_ONE
<< R300_DST_BLEND_SHIFT
);
284 eqnA
= R300_COMB_FCN_MAX
;
285 funcA
= (R300_BLEND_GL_ONE
<< R300_SRC_BLEND_SHIFT
) |
286 (R300_BLEND_GL_ONE
<< R300_DST_BLEND_SHIFT
);
291 "[%s:%u] Invalid A blend equation (0x%04x).\n",
292 __FUNCTION__
, __LINE__
, ctx
->Color
.BlendEquationA
);
296 r300SetBlendCntl(r300
,
298 R300_BLEND_UNKNOWN
| R300_BLEND_ENABLE
, funcA
, eqnA
);
301 static void r300BlendEquationSeparate(GLcontext
* ctx
,
302 GLenum modeRGB
, GLenum modeA
)
304 r300SetBlendState(ctx
);
307 static void r300BlendFuncSeparate(GLcontext
* ctx
,
308 GLenum sfactorRGB
, GLenum dfactorRGB
,
309 GLenum sfactorA
, GLenum dfactorA
)
311 r300SetBlendState(ctx
);
314 static void r300ClipPlane( GLcontext
*ctx
, GLenum plane
, const GLfloat
*eq
)
316 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
320 /* no VAP UCP on non-TCL chipsets */
321 if (!(rmesa
->radeon
.radeonScreen
->chip_flags
& RADEON_CHIPSET_TCL
))
324 p
= (GLint
) plane
- (GLint
) GL_CLIP_PLANE0
;
325 ip
= (GLint
*)ctx
->Transform
._ClipUserPlane
[p
];
327 R300_STATECHANGE( rmesa
, vpucp
[p
] );
328 rmesa
->hw
.vpucp
[p
].cmd
[R300_VPUCP_X
] = ip
[0];
329 rmesa
->hw
.vpucp
[p
].cmd
[R300_VPUCP_Y
] = ip
[1];
330 rmesa
->hw
.vpucp
[p
].cmd
[R300_VPUCP_Z
] = ip
[2];
331 rmesa
->hw
.vpucp
[p
].cmd
[R300_VPUCP_W
] = ip
[3];
334 static void r300SetClipPlaneState(GLcontext
* ctx
, GLenum cap
, GLboolean state
)
336 r300ContextPtr r300
= R300_CONTEXT(ctx
);
339 /* no VAP UCP on non-TCL chipsets */
340 if (!(r300
->radeon
.radeonScreen
->chip_flags
& RADEON_CHIPSET_TCL
))
343 p
= cap
- GL_CLIP_PLANE0
;
344 R300_STATECHANGE(r300
, vap_clip_cntl
);
346 r300
->hw
.vap_clip_cntl
.cmd
[1] |= (R300_VAP_UCP_ENABLE_0
<< p
);
347 r300ClipPlane(ctx
, cap
, NULL
);
349 r300
->hw
.vap_clip_cntl
.cmd
[1] &= ~(R300_VAP_UCP_ENABLE_0
<< p
);
354 * Update our tracked culling state based on Mesa's state.
356 static void r300UpdateCulling(GLcontext
* ctx
)
358 r300ContextPtr r300
= R300_CONTEXT(ctx
);
361 if (ctx
->Polygon
.CullFlag
) {
362 switch (ctx
->Polygon
.CullFaceMode
) {
364 val
= R300_CULL_FRONT
;
367 val
= R300_CULL_BACK
;
369 case GL_FRONT_AND_BACK
:
370 val
= R300_CULL_FRONT
| R300_CULL_BACK
;
377 switch (ctx
->Polygon
.FrontFace
) {
379 val
|= R300_FRONT_FACE_CW
;
382 val
|= R300_FRONT_FACE_CCW
;
388 R300_STATECHANGE(r300
, cul
);
389 r300
->hw
.cul
.cmd
[R300_CUL_CULL
] = val
;
392 static void r300SetPolygonOffsetState(GLcontext
* ctx
, GLboolean state
)
394 r300ContextPtr r300
= R300_CONTEXT(ctx
);
396 R300_STATECHANGE(r300
, occlusion_cntl
);
398 r300
->hw
.occlusion_cntl
.cmd
[1] |= (3 << 0);
400 r300
->hw
.occlusion_cntl
.cmd
[1] &= ~(3 << 0);
404 static void r300SetEarlyZState(GLcontext
* ctx
)
406 /* updates register R300_RB3D_EARLY_Z (0x4F14)
407 if depth test is not enabled it should be R300_EARLY_Z_DISABLE
408 if depth is enabled and alpha not it should be R300_EARLY_Z_ENABLE
409 if depth and alpha is enabled it should be R300_EARLY_Z_DISABLE
411 r300ContextPtr r300
= R300_CONTEXT(ctx
);
413 R300_STATECHANGE(r300
, zstencil_format
);
414 switch (ctx
->Visual
.depthBits
) {
416 r300
->hw
.zstencil_format
.cmd
[1] = ZB_FORMAR_DEPTHFORMAT_16BIT_INT_Z
;
419 r300
->hw
.zstencil_format
.cmd
[1] = ZB_FORMAR_DEPTHFORMAT_24BIT_INT_Z
;
422 fprintf(stderr
, "Error: Unsupported depth %d... exiting\n", ctx
->Visual
.depthBits
);
426 if (ctx
->Color
.AlphaEnabled
&& ctx
->Color
.AlphaFunc
!= GL_ALWAYS
)
427 /* disable early Z */
428 r300
->hw
.zstencil_format
.cmd
[2] = R300_EARLY_Z_DISABLE
;
430 if (ctx
->Depth
.Test
&& ctx
->Depth
.Func
!= GL_NEVER
)
432 r300
->hw
.zstencil_format
.cmd
[2] = R300_EARLY_Z_ENABLE
;
434 /* disable early Z */
435 r300
->hw
.zstencil_format
.cmd
[2] = R300_EARLY_Z_DISABLE
;
438 r300
->hw
.zstencil_format
.cmd
[3] = 0x00000003;
439 r300
->hw
.zstencil_format
.cmd
[4] = 0x00000000;
442 static void r300SetAlphaState(GLcontext
* ctx
)
444 r300ContextPtr r300
= R300_CONTEXT(ctx
);
446 uint32_t pp_misc
= 0x0;
447 GLboolean really_enabled
= ctx
->Color
.AlphaEnabled
;
449 CLAMPED_FLOAT_TO_UBYTE(refByte
, ctx
->Color
.AlphaRef
);
451 switch (ctx
->Color
.AlphaFunc
) {
453 pp_misc
|= FG_ALPHA_FUNC_NEVER
;
456 pp_misc
|= FG_ALPHA_FUNC_LESS
;
459 pp_misc
|= FG_ALPHA_FUNC_EQUAL
;
462 pp_misc
|= FG_ALPHA_FUNC_LE
;
465 pp_misc
|= FG_ALPHA_FUNC_GREATER
;
468 pp_misc
|= FG_ALPHA_FUNC_NOTEQUAL
;
471 pp_misc
|= FG_ALPHA_FUNC_GE
;
474 /*pp_misc |= FG_ALPHA_FUNC_ALWAYS; */
475 really_enabled
= GL_FALSE
;
479 if (really_enabled
) {
480 pp_misc
|= FG_ALPHA_FUNC_ENABLE
;
481 pp_misc
|= (refByte
& R300_REF_ALPHA_MASK
);
486 R300_STATECHANGE(r300
, at
);
487 r300
->hw
.at
.cmd
[R300_AT_ALPHA_TEST
] = pp_misc
;
488 r300
->hw
.at
.cmd
[R300_AT_UNKNOWN
] = 0;
490 r300SetEarlyZState(ctx
);
493 static void r300AlphaFunc(GLcontext
* ctx
, GLenum func
, GLfloat ref
)
497 r300SetAlphaState(ctx
);
500 static int translate_func(int func
)
504 return R300_ZS_NEVER
;
508 return R300_ZS_EQUAL
;
510 return R300_ZS_LEQUAL
;
512 return R300_ZS_GREATER
;
514 return R300_ZS_NOTEQUAL
;
516 return R300_ZS_GEQUAL
;
518 return R300_ZS_ALWAYS
;
523 static void r300SetDepthState(GLcontext
* ctx
)
525 r300ContextPtr r300
= R300_CONTEXT(ctx
);
527 R300_STATECHANGE(r300
, zs
);
528 r300
->hw
.zs
.cmd
[R300_ZS_CNTL_0
] &= R300_RB3D_STENCIL_ENABLE
;
529 r300
->hw
.zs
.cmd
[R300_ZS_CNTL_1
] &=
530 ~(R300_ZS_MASK
<< R300_RB3D_ZS1_DEPTH_FUNC_SHIFT
);
532 if (ctx
->Depth
.Test
&& ctx
->Depth
.Func
!= GL_NEVER
) {
534 r300
->hw
.zs
.cmd
[R300_ZS_CNTL_0
] |=
535 R300_RB3D_Z_TEST_AND_WRITE
;
537 r300
->hw
.zs
.cmd
[R300_ZS_CNTL_0
] |= R300_RB3D_Z_TEST
;
539 r300
->hw
.zs
.cmd
[R300_ZS_CNTL_1
] |=
540 translate_func(ctx
->Depth
.
541 Func
) << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT
;
543 r300
->hw
.zs
.cmd
[R300_ZS_CNTL_0
] |= R300_RB3D_Z_DISABLED_1
;
544 r300
->hw
.zs
.cmd
[R300_ZS_CNTL_1
] |=
545 translate_func(GL_NEVER
) << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT
;
548 r300SetEarlyZState(ctx
);
551 static void r300SetStencilState(GLcontext
* ctx
, GLboolean state
)
553 r300ContextPtr r300
= R300_CONTEXT(ctx
);
555 if (r300
->state
.stencil
.hw_stencil
) {
556 R300_STATECHANGE(r300
, zs
);
558 r300
->hw
.zs
.cmd
[R300_ZS_CNTL_0
] |=
559 R300_RB3D_STENCIL_ENABLE
;
561 r300
->hw
.zs
.cmd
[R300_ZS_CNTL_0
] &=
562 ~R300_RB3D_STENCIL_ENABLE
;
566 FALLBACK(&r300
->radeon
, RADEON_FALLBACK_STENCIL
, state
);
571 static void r300UpdatePolygonMode(GLcontext
* ctx
)
573 r300ContextPtr r300
= R300_CONTEXT(ctx
);
574 uint32_t hw_mode
= GA_POLY_MODE_DISABLE
;
576 /* Only do something if a polygon mode is wanted, default is GL_FILL */
577 if (ctx
->Polygon
.FrontMode
!= GL_FILL
||
578 ctx
->Polygon
.BackMode
!= GL_FILL
) {
581 /* Handle GL_CW (clock wise and GL_CCW (counter clock wise)
582 * correctly by selecting the correct front and back face
584 if (ctx
->Polygon
.FrontFace
== GL_CCW
) {
585 f
= ctx
->Polygon
.FrontMode
;
586 b
= ctx
->Polygon
.BackMode
;
588 f
= ctx
->Polygon
.BackMode
;
589 b
= ctx
->Polygon
.FrontMode
;
592 /* Enable polygon mode */
593 hw_mode
|= GA_POLY_MODE_DUAL
;
597 hw_mode
|= GA_POLY_MODE_FRONT_PTYPE_LINE
;
600 hw_mode
|= GA_POLY_MODE_FRONT_PTYPE_POINT
;
603 hw_mode
|= GA_POLY_MODE_FRONT_PTYPE_TRI
;
609 hw_mode
|= GA_POLY_MODE_BACK_PTYPE_LINE
;
612 hw_mode
|= GA_POLY_MODE_BACK_PTYPE_POINT
;
615 hw_mode
|= GA_POLY_MODE_BACK_PTYPE_TRI
;
620 if (r300
->hw
.polygon_mode
.cmd
[1] != hw_mode
) {
621 R300_STATECHANGE(r300
, polygon_mode
);
622 r300
->hw
.polygon_mode
.cmd
[1] = hw_mode
;
625 r300
->hw
.polygon_mode
.cmd
[2] = 0x00000001;
626 r300
->hw
.polygon_mode
.cmd
[3] = 0x00000000;
630 * Change the culling mode.
632 * \note Mesa already filters redundant calls to this function.
634 static void r300CullFace(GLcontext
* ctx
, GLenum mode
)
638 r300UpdateCulling(ctx
);
642 * Change the polygon orientation.
644 * \note Mesa already filters redundant calls to this function.
646 static void r300FrontFace(GLcontext
* ctx
, GLenum mode
)
650 r300UpdateCulling(ctx
);
651 r300UpdatePolygonMode(ctx
);
655 * Change the depth testing function.
657 * \note Mesa already filters redundant calls to this function.
659 static void r300DepthFunc(GLcontext
* ctx
, GLenum func
)
662 r300SetDepthState(ctx
);
666 * Enable/Disable depth writing.
668 * \note Mesa already filters redundant calls to this function.
670 static void r300DepthMask(GLcontext
* ctx
, GLboolean mask
)
673 r300SetDepthState(ctx
);
677 * Handle glColorMask()
679 static void r300ColorMask(GLcontext
* ctx
,
680 GLboolean r
, GLboolean g
, GLboolean b
, GLboolean a
)
682 r300ContextPtr r300
= R300_CONTEXT(ctx
);
683 int mask
= (r
? RB3D_COLOR_CHANNEL_MASK_RED_MASK0
: 0) |
684 (g
? RB3D_COLOR_CHANNEL_MASK_GREEN_MASK0
: 0) |
685 (b
? RB3D_COLOR_CHANNEL_MASK_BLUE_MASK0
: 0) |
686 (a
? RB3D_COLOR_CHANNEL_MASK_ALPHA_MASK0
: 0);
688 if (mask
!= r300
->hw
.cmk
.cmd
[R300_CMK_COLORMASK
]) {
689 R300_STATECHANGE(r300
, cmk
);
690 r300
->hw
.cmk
.cmd
[R300_CMK_COLORMASK
] = mask
;
694 /* =============================================================
697 static void r300Fogfv(GLcontext
* ctx
, GLenum pname
, const GLfloat
* param
)
699 r300ContextPtr r300
= R300_CONTEXT(ctx
);
703 } fogScale
, fogStart
;
707 fogScale
.i
= r300
->hw
.fogp
.cmd
[R300_FOGP_SCALE
];
708 fogStart
.i
= r300
->hw
.fogp
.cmd
[R300_FOGP_START
];
712 if (!ctx
->Fog
.Enabled
)
714 switch (ctx
->Fog
.Mode
) {
716 R300_STATECHANGE(r300
, fogs
);
717 r300
->hw
.fogs
.cmd
[R300_FOGS_STATE
] =
719 cmd
[R300_FOGS_STATE
] & ~FG_FOG_BLEND_FN_MASK
) |
720 FG_FOG_BLEND_FN_LINEAR
;
722 if (ctx
->Fog
.Start
== ctx
->Fog
.End
) {
727 1.0 / (ctx
->Fog
.End
- ctx
->Fog
.Start
);
729 -ctx
->Fog
.Start
/ (ctx
->Fog
.End
-
734 R300_STATECHANGE(r300
, fogs
);
735 r300
->hw
.fogs
.cmd
[R300_FOGS_STATE
] =
737 cmd
[R300_FOGS_STATE
] & ~FG_FOG_BLEND_FN_MASK
) |
739 fogScale
.f
= 0.0933 * ctx
->Fog
.Density
;
743 R300_STATECHANGE(r300
, fogs
);
744 r300
->hw
.fogs
.cmd
[R300_FOGS_STATE
] =
746 cmd
[R300_FOGS_STATE
] & ~FG_FOG_BLEND_FN_MASK
) |
747 FG_FOG_BLEND_FN_EXP2
;
748 fogScale
.f
= 0.3 * ctx
->Fog
.Density
;
755 switch (ctx
->Fog
.Mode
) {
757 fogScale
.f
= 0.0933 * ctx
->Fog
.Density
;
761 fogScale
.f
= 0.3 * ctx
->Fog
.Density
;
769 if (ctx
->Fog
.Mode
== GL_LINEAR
) {
770 if (ctx
->Fog
.Start
== ctx
->Fog
.End
) {
775 1.0 / (ctx
->Fog
.End
- ctx
->Fog
.Start
);
777 -ctx
->Fog
.Start
/ (ctx
->Fog
.End
-
783 R300_STATECHANGE(r300
, fogc
);
784 r300
->hw
.fogc
.cmd
[R300_FOGC_R
] =
785 (GLuint
) (ctx
->Fog
.Color
[0] * 1023.0F
) & 0x3FF;
786 r300
->hw
.fogc
.cmd
[R300_FOGC_G
] =
787 (GLuint
) (ctx
->Fog
.Color
[1] * 1023.0F
) & 0x3FF;
788 r300
->hw
.fogc
.cmd
[R300_FOGC_B
] =
789 (GLuint
) (ctx
->Fog
.Color
[2] * 1023.0F
) & 0x3FF;
791 case GL_FOG_COORD_SRC
:
797 if (fogScale
.i
!= r300
->hw
.fogp
.cmd
[R300_FOGP_SCALE
] ||
798 fogStart
.i
!= r300
->hw
.fogp
.cmd
[R300_FOGP_START
]) {
799 R300_STATECHANGE(r300
, fogp
);
800 r300
->hw
.fogp
.cmd
[R300_FOGP_SCALE
] = fogScale
.i
;
801 r300
->hw
.fogp
.cmd
[R300_FOGP_START
] = fogStart
.i
;
805 static void r300SetFogState(GLcontext
* ctx
, GLboolean state
)
807 r300ContextPtr r300
= R300_CONTEXT(ctx
);
809 R300_STATECHANGE(r300
, fogs
);
811 r300
->hw
.fogs
.cmd
[R300_FOGS_STATE
] |= FG_FOG_BLEND_ENABLE
;
813 r300Fogfv(ctx
, GL_FOG_MODE
, NULL
);
814 r300Fogfv(ctx
, GL_FOG_DENSITY
, &ctx
->Fog
.Density
);
815 r300Fogfv(ctx
, GL_FOG_START
, &ctx
->Fog
.Start
);
816 r300Fogfv(ctx
, GL_FOG_END
, &ctx
->Fog
.End
);
817 r300Fogfv(ctx
, GL_FOG_COLOR
, ctx
->Fog
.Color
);
819 r300
->hw
.fogs
.cmd
[R300_FOGS_STATE
] &= ~FG_FOG_BLEND_ENABLE
;
823 /* =============================================================
826 static void r300PointSize(GLcontext
* ctx
, GLfloat size
)
828 r300ContextPtr r300
= R300_CONTEXT(ctx
);
829 /* same size limits for AA, non-AA points */
830 size
= CLAMP(size
, ctx
->Const
.MinPointSize
, ctx
->Const
.MaxPointSize
);
832 R300_STATECHANGE(r300
, ps
);
833 r300
->hw
.ps
.cmd
[R300_PS_POINTSIZE
] =
834 ((int)(size
* 6) << R300_POINTSIZE_X_SHIFT
) |
835 ((int)(size
* 6) << R300_POINTSIZE_Y_SHIFT
);
838 /* =============================================================
841 static void r300LineWidth(GLcontext
* ctx
, GLfloat widthf
)
843 r300ContextPtr r300
= R300_CONTEXT(ctx
);
845 widthf
= CLAMP(widthf
,
846 ctx
->Const
.MinPointSize
,
847 ctx
->Const
.MaxPointSize
);
848 R300_STATECHANGE(r300
, lcntl
);
849 r300
->hw
.lcntl
.cmd
[1] =
850 R300_LINE_CNT_HO
| R300_LINE_CNT_VE
| (int)(widthf
* 6.0);
853 static void r300PolygonMode(GLcontext
* ctx
, GLenum face
, GLenum mode
)
858 r300UpdatePolygonMode(ctx
);
861 /* =============================================================
865 static int translate_stencil_op(int op
)
873 return R300_ZS_REPLACE
;
878 case GL_INCR_WRAP_EXT
:
879 return R300_ZS_INCR_WRAP
;
880 case GL_DECR_WRAP_EXT
:
881 return R300_ZS_DECR_WRAP
;
883 return R300_ZS_INVERT
;
885 WARN_ONCE("Do not know how to translate stencil op");
891 static void r300ShadeModel(GLcontext
* ctx
, GLenum mode
)
893 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
895 R300_STATECHANGE(rmesa
, shade
);
896 rmesa
->hw
.shade
.cmd
[1] = 0x00000002;
899 rmesa
->hw
.shade
.cmd
[2] = R300_RE_SHADE_MODEL_FLAT
;
902 rmesa
->hw
.shade
.cmd
[2] = R300_RE_SHADE_MODEL_SMOOTH
;
907 rmesa
->hw
.shade
.cmd
[3] = 0x00000000;
908 rmesa
->hw
.shade
.cmd
[4] = 0x00000000;
911 static void r300StencilFuncSeparate(GLcontext
* ctx
, GLenum face
,
912 GLenum func
, GLint ref
, GLuint mask
)
914 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
917 Ref
[0] & 0xff) << ZB_STENCILREFMASK_STENCILREF_SHIFT
) | ((ctx
->
923 ZB_STENCILREFMASK_STENCILMASK_SHIFT
));
927 R300_STATECHANGE(rmesa
, zs
);
929 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_1
] &= ~((R300_ZS_MASK
<<
930 R300_RB3D_ZS1_FRONT_FUNC_SHIFT
)
932 R300_RB3D_ZS1_BACK_FUNC_SHIFT
));
934 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_2
] &=
935 ~((ZB_STENCILREFMASK_STENCILREF_MASK
<< ZB_STENCILREFMASK_STENCILREF_SHIFT
) |
936 (ZB_STENCILREFMASK_STENCILMASK_MASK
<< ZB_STENCILREFMASK_STENCILMASK_SHIFT
));
938 flag
= translate_func(ctx
->Stencil
.Function
[0]);
939 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_1
] |=
940 (flag
<< R300_RB3D_ZS1_FRONT_FUNC_SHIFT
);
942 if (ctx
->Stencil
._TestTwoSide
)
943 flag
= translate_func(ctx
->Stencil
.Function
[1]);
945 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_1
] |=
946 (flag
<< R300_RB3D_ZS1_BACK_FUNC_SHIFT
);
947 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_2
] |= refmask
;
950 static void r300StencilMaskSeparate(GLcontext
* ctx
, GLenum face
, GLuint mask
)
952 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
954 R300_STATECHANGE(rmesa
, zs
);
955 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_2
] &=
956 ~(ZB_STENCILREFMASK_STENCILMASK_MASK
<<
957 ZB_STENCILREFMASK_STENCILWRITEMASK_SHIFT
);
958 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_2
] |=
960 WriteMask
[0] & 0xff) << ZB_STENCILREFMASK_STENCILWRITEMASK_SHIFT
;
963 static void r300StencilOpSeparate(GLcontext
* ctx
, GLenum face
,
964 GLenum fail
, GLenum zfail
, GLenum zpass
)
966 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
968 R300_STATECHANGE(rmesa
, zs
);
969 /* It is easier to mask what's left.. */
970 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_1
] &=
971 (R300_ZS_MASK
<< R300_RB3D_ZS1_DEPTH_FUNC_SHIFT
) |
972 (R300_ZS_MASK
<< R300_RB3D_ZS1_FRONT_FUNC_SHIFT
) |
973 (R300_ZS_MASK
<< R300_RB3D_ZS1_BACK_FUNC_SHIFT
);
975 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_1
] |=
976 (translate_stencil_op(ctx
->Stencil
.FailFunc
[0]) <<
977 R300_RB3D_ZS1_FRONT_FAIL_OP_SHIFT
)
978 | (translate_stencil_op(ctx
->Stencil
.ZFailFunc
[0]) <<
979 R300_RB3D_ZS1_FRONT_ZFAIL_OP_SHIFT
)
980 | (translate_stencil_op(ctx
->Stencil
.ZPassFunc
[0]) <<
981 R300_RB3D_ZS1_FRONT_ZPASS_OP_SHIFT
);
983 if (ctx
->Stencil
._TestTwoSide
) {
984 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_1
] |=
985 (translate_stencil_op(ctx
->Stencil
.FailFunc
[1]) <<
986 R300_RB3D_ZS1_BACK_FAIL_OP_SHIFT
)
987 | (translate_stencil_op(ctx
->Stencil
.ZFailFunc
[1]) <<
988 R300_RB3D_ZS1_BACK_ZFAIL_OP_SHIFT
)
989 | (translate_stencil_op(ctx
->Stencil
.ZPassFunc
[1]) <<
990 R300_RB3D_ZS1_BACK_ZPASS_OP_SHIFT
);
992 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_1
] |=
993 (translate_stencil_op(ctx
->Stencil
.FailFunc
[0]) <<
994 R300_RB3D_ZS1_BACK_FAIL_OP_SHIFT
)
995 | (translate_stencil_op(ctx
->Stencil
.ZFailFunc
[0]) <<
996 R300_RB3D_ZS1_BACK_ZFAIL_OP_SHIFT
)
997 | (translate_stencil_op(ctx
->Stencil
.ZPassFunc
[0]) <<
998 R300_RB3D_ZS1_BACK_ZPASS_OP_SHIFT
);
1002 static void r300ClearStencil(GLcontext
* ctx
, GLint s
)
1004 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
1006 rmesa
->state
.stencil
.clear
=
1007 ((GLuint
) (ctx
->Stencil
.Clear
& 0xff) |
1008 (ZB_STENCILREFMASK_STENCILMASK_MASK
<<
1009 ZB_STENCILREFMASK_STENCILMASK_SHIFT
) | ((ctx
->Stencil
.
1010 WriteMask
[0] & 0xff) <<
1011 ZB_STENCILREFMASK_STENCILMASK_SHIFT
));
1014 /* =============================================================
1015 * Window position and viewport transformation
1019 * To correctly position primitives:
1021 #define SUBPIXEL_X 0.125
1022 #define SUBPIXEL_Y 0.125
1024 static void r300UpdateWindow(GLcontext
* ctx
)
1026 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
1027 __DRIdrawablePrivate
*dPriv
= rmesa
->radeon
.dri
.drawable
;
1028 GLfloat xoffset
= dPriv
? (GLfloat
) dPriv
->x
: 0;
1029 GLfloat yoffset
= dPriv
? (GLfloat
) dPriv
->y
+ dPriv
->h
: 0;
1030 const GLfloat
*v
= ctx
->Viewport
._WindowMap
.m
;
1032 GLfloat sx
= v
[MAT_SX
];
1033 GLfloat tx
= v
[MAT_TX
] + xoffset
+ SUBPIXEL_X
;
1034 GLfloat sy
= -v
[MAT_SY
];
1035 GLfloat ty
= (-v
[MAT_TY
]) + yoffset
+ SUBPIXEL_Y
;
1036 GLfloat sz
= v
[MAT_SZ
] * rmesa
->state
.depth
.scale
;
1037 GLfloat tz
= v
[MAT_TZ
] * rmesa
->state
.depth
.scale
;
1039 R300_FIREVERTICES(rmesa
);
1040 R300_STATECHANGE(rmesa
, vpt
);
1042 rmesa
->hw
.vpt
.cmd
[R300_VPT_XSCALE
] = r300PackFloat32(sx
);
1043 rmesa
->hw
.vpt
.cmd
[R300_VPT_XOFFSET
] = r300PackFloat32(tx
);
1044 rmesa
->hw
.vpt
.cmd
[R300_VPT_YSCALE
] = r300PackFloat32(sy
);
1045 rmesa
->hw
.vpt
.cmd
[R300_VPT_YOFFSET
] = r300PackFloat32(ty
);
1046 rmesa
->hw
.vpt
.cmd
[R300_VPT_ZSCALE
] = r300PackFloat32(sz
);
1047 rmesa
->hw
.vpt
.cmd
[R300_VPT_ZOFFSET
] = r300PackFloat32(tz
);
1050 static void r300Viewport(GLcontext
* ctx
, GLint x
, GLint y
,
1051 GLsizei width
, GLsizei height
)
1053 /* Don't pipeline viewport changes, conflict with window offset
1054 * setting below. Could apply deltas to rescue pipelined viewport
1055 * values, or keep the originals hanging around.
1057 r300UpdateWindow(ctx
);
1060 static void r300DepthRange(GLcontext
* ctx
, GLclampd nearval
, GLclampd farval
)
1062 r300UpdateWindow(ctx
);
1065 void r300UpdateViewportOffset(GLcontext
* ctx
)
1067 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
1068 __DRIdrawablePrivate
*dPriv
= ((radeonContextPtr
) rmesa
)->dri
.drawable
;
1069 GLfloat xoffset
= (GLfloat
) dPriv
->x
;
1070 GLfloat yoffset
= (GLfloat
) dPriv
->y
+ dPriv
->h
;
1071 const GLfloat
*v
= ctx
->Viewport
._WindowMap
.m
;
1073 GLfloat tx
= v
[MAT_TX
] + xoffset
+ SUBPIXEL_X
;
1074 GLfloat ty
= (-v
[MAT_TY
]) + yoffset
+ SUBPIXEL_Y
;
1076 if (rmesa
->hw
.vpt
.cmd
[R300_VPT_XOFFSET
] != r300PackFloat32(tx
) ||
1077 rmesa
->hw
.vpt
.cmd
[R300_VPT_YOFFSET
] != r300PackFloat32(ty
)) {
1078 /* Note: this should also modify whatever data the context reset
1081 R300_STATECHANGE(rmesa
, vpt
);
1082 rmesa
->hw
.vpt
.cmd
[R300_VPT_XOFFSET
] = r300PackFloat32(tx
);
1083 rmesa
->hw
.vpt
.cmd
[R300_VPT_YOFFSET
] = r300PackFloat32(ty
);
1087 radeonUpdateScissor(ctx
);
1091 * Tell the card where to render (offset, pitch).
1092 * Effected by glDrawBuffer, etc
1094 void r300UpdateDrawBuffer(GLcontext
* ctx
)
1096 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
1097 r300ContextPtr r300
= rmesa
;
1098 struct gl_framebuffer
*fb
= ctx
->DrawBuffer
;
1099 driRenderbuffer
*drb
;
1101 if (fb
->_ColorDrawBufferIndexes
[0] == BUFFER_FRONT_LEFT
) {
1104 (driRenderbuffer
*) fb
->Attachment
[BUFFER_FRONT_LEFT
].
1106 } else if (fb
->_ColorDrawBufferIndexes
[0] == BUFFER_BACK_LEFT
) {
1109 (driRenderbuffer
*) fb
->Attachment
[BUFFER_BACK_LEFT
].
1112 /* drawing to multiple buffers, or none */
1117 assert(drb
->flippedPitch
);
1119 R300_STATECHANGE(rmesa
, cb
);
1121 r300
->hw
.cb
.cmd
[R300_CB_OFFSET
] = drb
->flippedOffset
+ //r300->radeon.state.color.drawOffset +
1122 r300
->radeon
.radeonScreen
->fbLocation
;
1123 r300
->hw
.cb
.cmd
[R300_CB_PITCH
] = drb
->flippedPitch
; //r300->radeon.state.color.drawPitch;
1125 if (r300
->radeon
.radeonScreen
->cpp
== 4)
1126 r300
->hw
.cb
.cmd
[R300_CB_PITCH
] |= R300_COLOR_FORMAT_ARGB8888
;
1128 r300
->hw
.cb
.cmd
[R300_CB_PITCH
] |= R300_COLOR_FORMAT_RGB565
;
1130 if (r300
->radeon
.sarea
->tiling_enabled
)
1131 r300
->hw
.cb
.cmd
[R300_CB_PITCH
] |= R300_COLOR_TILE_ENABLE
;
1133 R200_STATECHANGE(rmesa
, ctx
);
1135 /* Note: we used the (possibly) page-flipped values */
1136 rmesa
->hw
.ctx
.cmd
[CTX_RB3D_COLOROFFSET
]
1137 = ((drb
->flippedOffset
+ rmesa
->r200Screen
->fbLocation
)
1138 & R200_COLOROFFSET_MASK
);
1139 rmesa
->hw
.ctx
.cmd
[CTX_RB3D_COLORPITCH
] = drb
->flippedPitch
;
1141 if (rmesa
->sarea
->tiling_enabled
) {
1142 rmesa
->hw
.ctx
.cmd
[CTX_RB3D_COLORPITCH
] |=
1143 R200_COLOR_TILE_ENABLE
;
1149 r300FetchStateParameter(GLcontext
* ctx
,
1150 const gl_state_index state
[STATE_LENGTH
],
1153 r300ContextPtr r300
= R300_CONTEXT(ctx
);
1156 case STATE_INTERNAL
:
1158 case STATE_R300_WINDOW_DIMENSION
:
1159 value
[0] = r300
->radeon
.dri
.drawable
->w
* 0.5f
; /* width*0.5 */
1160 value
[1] = r300
->radeon
.dri
.drawable
->h
* 0.5f
; /* height*0.5 */
1161 value
[2] = 0.5F
; /* for moving range [-1 1] -> [0 1] */
1162 value
[3] = 1.0F
; /* not used */
1165 case STATE_R300_TEXRECT_FACTOR
:{
1166 struct gl_texture_object
*t
=
1167 ctx
->Texture
.Unit
[state
[2]].CurrentRect
;
1169 if (t
&& t
->Image
[0][t
->BaseLevel
]) {
1170 struct gl_texture_image
*image
=
1171 t
->Image
[0][t
->BaseLevel
];
1172 value
[0] = 1.0 / image
->Width2
;
1173 value
[1] = 1.0 / image
->Height2
;
1194 * Update R300's own internal state parameters.
1195 * For now just STATE_R300_WINDOW_DIMENSION
1197 void r300UpdateStateParameters(GLcontext
* ctx
, GLuint new_state
)
1199 struct r300_fragment_program
*fp
;
1200 struct gl_program_parameter_list
*paramList
;
1203 if (!(new_state
& (_NEW_BUFFERS
| _NEW_PROGRAM
)))
1206 fp
= (struct r300_fragment_program
*)ctx
->FragmentProgram
._Current
;
1210 paramList
= fp
->mesa_program
.Base
.Parameters
;
1215 for (i
= 0; i
< paramList
->NumParameters
; i
++) {
1216 if (paramList
->Parameters
[i
].Type
== PROGRAM_STATE_VAR
) {
1217 r300FetchStateParameter(ctx
,
1218 paramList
->Parameters
[i
].
1220 paramList
->ParameterValues
[i
]);
1225 /* =============================================================
1228 static void r300PolygonOffset(GLcontext
* ctx
, GLfloat factor
, GLfloat units
)
1230 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
1231 GLfloat constant
= units
;
1233 switch (ctx
->Visual
.depthBits
) {
1244 /* fprintf(stderr, "%s f:%f u:%f\n", __FUNCTION__, factor, constant); */
1246 R300_STATECHANGE(rmesa
, zbs
);
1247 rmesa
->hw
.zbs
.cmd
[R300_ZBS_T_FACTOR
] = r300PackFloat32(factor
);
1248 rmesa
->hw
.zbs
.cmd
[R300_ZBS_T_CONSTANT
] = r300PackFloat32(constant
);
1249 rmesa
->hw
.zbs
.cmd
[R300_ZBS_W_FACTOR
] = r300PackFloat32(factor
);
1250 rmesa
->hw
.zbs
.cmd
[R300_ZBS_W_CONSTANT
] = r300PackFloat32(constant
);
1253 /* Routing and texture-related */
1255 /* r300 doesnt handle GL_CLAMP and GL_MIRROR_CLAMP_EXT correctly when filter is NEAREST.
1256 * Since texwrap produces same results for GL_CLAMP and GL_CLAMP_TO_EDGE we use them instead.
1257 * We need to recalculate wrap modes whenever filter mode is changed because someone might do:
1258 * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1259 * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
1260 * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1261 * Since r300 completely ignores R300_TX_CLAMP when either min or mag is nearest it cant handle
1262 * combinations where only one of them is nearest.
1264 static unsigned long gen_fixed_filter(unsigned long f
)
1266 unsigned long mag
, min
, needs_fixing
= 0;
1269 /* We ignore MIRROR bit so we dont have to do everything twice */
1270 if ((f
& ((7 - 1) << R300_TX_WRAP_S_SHIFT
)) ==
1271 (R300_TX_CLAMP
<< R300_TX_WRAP_S_SHIFT
)) {
1274 if ((f
& ((7 - 1) << R300_TX_WRAP_T_SHIFT
)) ==
1275 (R300_TX_CLAMP
<< R300_TX_WRAP_T_SHIFT
)) {
1278 if ((f
& ((7 - 1) << R300_TX_WRAP_Q_SHIFT
)) ==
1279 (R300_TX_CLAMP
<< R300_TX_WRAP_Q_SHIFT
)) {
1286 mag
= f
& R300_TX_MAG_FILTER_MASK
;
1287 min
= f
& R300_TX_MIN_FILTER_MASK
;
1289 /* TODO: Check for anisto filters too */
1290 if ((mag
!= R300_TX_MAG_FILTER_NEAREST
)
1291 && (min
!= R300_TX_MIN_FILTER_NEAREST
))
1294 /* r300 cant handle these modes hence we force nearest to linear */
1295 if ((mag
== R300_TX_MAG_FILTER_NEAREST
)
1296 && (min
!= R300_TX_MIN_FILTER_NEAREST
)) {
1297 f
&= ~R300_TX_MAG_FILTER_NEAREST
;
1298 f
|= R300_TX_MAG_FILTER_LINEAR
;
1302 if ((min
== R300_TX_MIN_FILTER_NEAREST
)
1303 && (mag
!= R300_TX_MAG_FILTER_NEAREST
)) {
1304 f
&= ~R300_TX_MIN_FILTER_NEAREST
;
1305 f
|= R300_TX_MIN_FILTER_LINEAR
;
1309 /* Both are nearest */
1310 if (needs_fixing
& 1) {
1311 f
&= ~((7 - 1) << R300_TX_WRAP_S_SHIFT
);
1312 f
|= R300_TX_CLAMP_TO_EDGE
<< R300_TX_WRAP_S_SHIFT
;
1314 if (needs_fixing
& 2) {
1315 f
&= ~((7 - 1) << R300_TX_WRAP_T_SHIFT
);
1316 f
|= R300_TX_CLAMP_TO_EDGE
<< R300_TX_WRAP_T_SHIFT
;
1318 if (needs_fixing
& 4) {
1319 f
&= ~((7 - 1) << R300_TX_WRAP_Q_SHIFT
);
1320 f
|= R300_TX_CLAMP_TO_EDGE
<< R300_TX_WRAP_Q_SHIFT
;
1325 static void r300SetupTextures(GLcontext
* ctx
)
1328 struct r300_tex_obj
*t
;
1329 r300ContextPtr r300
= R300_CONTEXT(ctx
);
1331 int last_hw_tmu
= -1; /* -1 translates into no setup costs for fields */
1332 int tmu_mappings
[R300_MAX_TEXTURE_UNITS
] = { -1, };
1333 struct r300_fragment_program
*fp
= (struct r300_fragment_program
*)
1334 (char *)ctx
->FragmentProgram
._Current
;
1336 R300_STATECHANGE(r300
, txe
);
1337 R300_STATECHANGE(r300
, tex
.filter
);
1338 R300_STATECHANGE(r300
, tex
.filter_1
);
1339 R300_STATECHANGE(r300
, tex
.size
);
1340 R300_STATECHANGE(r300
, tex
.format
);
1341 R300_STATECHANGE(r300
, tex
.pitch
);
1342 R300_STATECHANGE(r300
, tex
.offset
);
1343 R300_STATECHANGE(r300
, tex
.chroma_key
);
1344 R300_STATECHANGE(r300
, tex
.border_color
);
1346 r300
->hw
.txe
.cmd
[R300_TXE_ENABLE
] = 0x0;
1348 mtu
= r300
->radeon
.glCtx
->Const
.MaxTextureUnits
;
1349 if (RADEON_DEBUG
& DEBUG_STATE
)
1350 fprintf(stderr
, "mtu=%d\n", mtu
);
1352 if (mtu
> R300_MAX_TEXTURE_UNITS
) {
1354 "Aiiee ! mtu=%d is greater than R300_MAX_TEXTURE_UNITS=%d\n",
1355 mtu
, R300_MAX_TEXTURE_UNITS
);
1359 /* We cannot let disabled tmu offsets pass DRM */
1360 for (i
= 0; i
< mtu
; i
++) {
1361 if (ctx
->Texture
.Unit
[i
]._ReallyEnabled
) {
1363 #if 0 /* Enables old behaviour */
1366 tmu_mappings
[i
] = hw_tmu
;
1368 t
= r300
->state
.texture
.unit
[i
].texobj
;
1369 /* XXX questionable fix for bug 9170: */
1373 if ((t
->format
& 0xffffff00) == 0xffffff00) {
1375 ("unknown texture format (entry %x) encountered. Help me !\n",
1379 if (RADEON_DEBUG
& DEBUG_STATE
)
1381 "Activating texture unit %d\n", i
);
1383 r300
->hw
.txe
.cmd
[R300_TXE_ENABLE
] |= (1 << hw_tmu
);
1385 r300
->hw
.tex
.filter
.cmd
[R300_TEX_VALUE_0
+
1387 gen_fixed_filter(t
->filter
) | (hw_tmu
<< 28);
1388 /* Currently disabled! */
1389 r300
->hw
.tex
.filter_1
.cmd
[R300_TEX_VALUE_0
+ hw_tmu
] = 0x0; //0x20501f80;
1390 r300
->hw
.tex
.size
.cmd
[R300_TEX_VALUE_0
+ hw_tmu
] =
1392 r300
->hw
.tex
.format
.cmd
[R300_TEX_VALUE_0
+
1393 hw_tmu
] = t
->format
;
1394 r300
->hw
.tex
.pitch
.cmd
[R300_TEX_VALUE_0
+ hw_tmu
] =
1396 r300
->hw
.tex
.offset
.cmd
[R300_TEX_VALUE_0
+
1397 hw_tmu
] = t
->offset
;
1399 if (t
->offset
& R300_TXO_MACRO_TILE
) {
1400 WARN_ONCE("macro tiling enabled!\n");
1403 if (t
->offset
& R300_TXO_MICRO_TILE
) {
1404 WARN_ONCE("micro tiling enabled!\n");
1407 r300
->hw
.tex
.chroma_key
.cmd
[R300_TEX_VALUE_0
+
1409 r300
->hw
.tex
.border_color
.cmd
[R300_TEX_VALUE_0
+
1413 last_hw_tmu
= hw_tmu
;
1419 r300
->hw
.tex
.filter
.cmd
[R300_TEX_CMD_0
] =
1420 cmdpacket0(R300_TX_FILTER0_0
, last_hw_tmu
+ 1);
1421 r300
->hw
.tex
.filter_1
.cmd
[R300_TEX_CMD_0
] =
1422 cmdpacket0(R300_TX_FILTER1_0
, last_hw_tmu
+ 1);
1423 r300
->hw
.tex
.size
.cmd
[R300_TEX_CMD_0
] =
1424 cmdpacket0(R300_TX_SIZE_0
, last_hw_tmu
+ 1);
1425 r300
->hw
.tex
.format
.cmd
[R300_TEX_CMD_0
] =
1426 cmdpacket0(R300_TX_FORMAT_0
, last_hw_tmu
+ 1);
1427 r300
->hw
.tex
.pitch
.cmd
[R300_TEX_CMD_0
] =
1428 cmdpacket0(R300_TX_FORMAT2_0
, last_hw_tmu
+ 1);
1429 r300
->hw
.tex
.offset
.cmd
[R300_TEX_CMD_0
] =
1430 cmdpacket0(R300_TX_OFFSET_0
, last_hw_tmu
+ 1);
1431 r300
->hw
.tex
.chroma_key
.cmd
[R300_TEX_CMD_0
] =
1432 cmdpacket0(R300_TX_CHROMA_KEY_0
, last_hw_tmu
+ 1);
1433 r300
->hw
.tex
.border_color
.cmd
[R300_TEX_CMD_0
] =
1434 cmdpacket0(R300_TX_BORDER_COLOR_0
, last_hw_tmu
+ 1);
1436 if (!fp
) /* should only happenen once, just after context is created */
1439 R300_STATECHANGE(r300
, fpt
);
1441 for (i
= 0; i
< fp
->tex
.length
; i
++) {
1446 unit
= fp
->tex
.inst
[i
] >> R300_FPITX_IMAGE_SHIFT
;
1449 val
= fp
->tex
.inst
[i
];
1450 val
&= ~R300_FPITX_IMAGE_MASK
;
1453 (val
& R300_FPITX_OPCODE_MASK
) >> R300_FPITX_OPCODE_SHIFT
;
1454 if (opcode
== R300_FPITX_OP_KIL
) {
1455 r300
->hw
.fpt
.cmd
[R300_FPT_INSTR_0
+ i
] = val
;
1457 if (tmu_mappings
[unit
] >= 0) {
1459 tmu_mappings
[unit
] <<
1460 R300_FPITX_IMAGE_SHIFT
;
1461 r300
->hw
.fpt
.cmd
[R300_FPT_INSTR_0
+ i
] = val
;
1463 // We get here when the corresponding texture image is incomplete
1464 // (e.g. incomplete mipmaps etc.)
1465 r300
->hw
.fpt
.cmd
[R300_FPT_INSTR_0
+ i
] = val
;
1470 r300
->hw
.fpt
.cmd
[R300_FPT_CMD_0
] =
1471 cmdpacket0(R300_PFS_TEXI_0
, fp
->tex
.length
);
1473 if (RADEON_DEBUG
& DEBUG_STATE
)
1474 fprintf(stderr
, "TX_ENABLE: %08x last_hw_tmu=%d\n",
1475 r300
->hw
.txe
.cmd
[R300_TXE_ENABLE
], last_hw_tmu
);
1478 union r300_outputs_written
{
1479 GLuint vp_outputs
; /* hw_tcl_on */
1480 DECLARE_RENDERINPUTS(index_bitset
); /* !hw_tcl_on */
1483 #define R300_OUTPUTS_WRITTEN_TEST(ow, vp_result, tnl_attrib) \
1484 ((hw_tcl_on) ? (ow).vp_outputs & (1 << (vp_result)) : \
1485 RENDERINPUTS_TEST( (ow.index_bitset), (tnl_attrib) ))
1487 static void r300SetupRSUnit(GLcontext
* ctx
)
1489 r300ContextPtr r300
= R300_CONTEXT(ctx
);
1490 /* I'm still unsure if these are needed */
1491 GLuint interp_magic
[8] = {
1501 union r300_outputs_written OutputsWritten
;
1503 int fp_reg
, high_rr
;
1504 int in_texcoords
, col_interp_nr
;
1508 OutputsWritten
.vp_outputs
= CURRENT_VERTEX_SHADER(ctx
)->key
.OutputsWritten
;
1510 RENDERINPUTS_COPY(OutputsWritten
.index_bitset
, r300
->state
.render_inputs_bitset
);
1512 if (ctx
->FragmentProgram
._Current
)
1513 InputsRead
= ctx
->FragmentProgram
._Current
->Base
.InputsRead
;
1515 fprintf(stderr
, "No ctx->FragmentProgram._Current!!\n");
1516 return; /* This should only ever happen once.. */
1519 R300_STATECHANGE(r300
, ri
);
1520 R300_STATECHANGE(r300
, rc
);
1521 R300_STATECHANGE(r300
, rr
);
1523 fp_reg
= in_texcoords
= col_interp_nr
= high_rr
= 0;
1525 r300
->hw
.rr
.cmd
[R300_RR_ROUTE_1
] = 0;
1527 if (InputsRead
& FRAG_BIT_WPOS
) {
1528 for (i
= 0; i
< ctx
->Const
.MaxTextureUnits
; i
++)
1529 if (!(InputsRead
& (FRAG_BIT_TEX0
<< i
)))
1532 if (i
== ctx
->Const
.MaxTextureUnits
) {
1533 fprintf(stderr
, "\tno free texcoord found...\n");
1537 InputsRead
|= (FRAG_BIT_TEX0
<< i
);
1538 InputsRead
&= ~FRAG_BIT_WPOS
;
1541 for (i
= 0; i
< ctx
->Const
.MaxTextureUnits
; i
++) {
1542 r300
->hw
.ri
.cmd
[R300_RI_INTERP_0
+ i
] = 0 | R300_RS_SEL_T(1) | R300_RS_SEL_R(2) | R300_RS_SEL_Q(3) | (in_texcoords
<< R300_RS_INTERP_SRC_SHIFT
)
1545 r300
->hw
.rr
.cmd
[R300_RR_ROUTE_0
+ fp_reg
] = 0;
1546 if (InputsRead
& (FRAG_BIT_TEX0
<< i
)) {
1547 //assert(r300->state.texture.tc_count != 0);
1548 r300
->hw
.rr
.cmd
[R300_RR_ROUTE_0
+ fp_reg
] |= R300_RS_ROUTE_ENABLE
| i
/* source INTERP */
1549 | (fp_reg
<< R300_RS_ROUTE_DEST_SHIFT
);
1552 /* Passing invalid data here can lock the GPU. */
1553 if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten
, VERT_RESULT_TEX0
+ i
, _TNL_ATTRIB_TEX(i
))) {
1554 InputsRead
&= ~(FRAG_BIT_TEX0
<< i
);
1557 WARN_ONCE("fragprog wants coords for tex%d, vp doesn't provide them!\n", i
);
1560 /* Need to count all coords enabled at vof */
1561 if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten
, VERT_RESULT_TEX0
+ i
, _TNL_ATTRIB_TEX(i
))) {
1566 if (InputsRead
& FRAG_BIT_COL0
) {
1567 if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten
, VERT_RESULT_COL0
, _TNL_ATTRIB_COLOR0
)) {
1568 r300
->hw
.rr
.cmd
[R300_RR_ROUTE_0
] |= 0 | R300_RS_ROUTE_0_COLOR
| (fp_reg
++ << R300_RS_ROUTE_0_COLOR_DEST_SHIFT
);
1569 InputsRead
&= ~FRAG_BIT_COL0
;
1572 WARN_ONCE("fragprog wants col0, vp doesn't provide it\n");
1576 if (InputsRead
& FRAG_BIT_COL1
) {
1577 if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten
, VERT_RESULT_COL1
, _TNL_ATTRIB_COLOR1
)) {
1578 r300
->hw
.rr
.cmd
[R300_RR_ROUTE_1
] |= R300_RS_ROUTE_1_UNKNOWN11
| R300_RS_ROUTE_1_COLOR1
| (fp_reg
++ << R300_RS_ROUTE_1_COLOR1_DEST_SHIFT
);
1579 InputsRead
&= ~FRAG_BIT_COL1
;
1584 WARN_ONCE("fragprog wants col1, vp doesn't provide it\n");
1588 /* Need at least one. This might still lock as the values are undefined... */
1589 if (in_texcoords
== 0 && col_interp_nr
== 0) {
1590 r300
->hw
.rr
.cmd
[R300_RR_ROUTE_0
] |= 0 | R300_RS_ROUTE_0_COLOR
| (fp_reg
++ << R300_RS_ROUTE_0_COLOR_DEST_SHIFT
);
1594 r300
->hw
.rc
.cmd
[1] = 0 | ((in_texcoords
<< 2) << R300_IT_COUNT_SHIFT
)
1595 | (col_interp_nr
<< R300_IC_COUNT_SHIFT
)
1598 assert(high_rr
>= 0);
1599 r300
->hw
.rr
.cmd
[R300_RR_CMD_0
] = cmdpacket0(R300_RS_ROUTE_0
, high_rr
+ 1);
1600 r300
->hw
.rc
.cmd
[2] = 0xC0 | high_rr
;
1603 WARN_ONCE("Don't know how to satisfy InputsRead=0x%08x\n", InputsRead
);
1606 #define bump_vpu_count(ptr, new_count) do{\
1607 drm_r300_cmd_header_t* _p=((drm_r300_cmd_header_t*)(ptr));\
1608 int _nc=(new_count)/4; \
1609 assert(_nc < 256); \
1610 if(_nc>_p->vpu.count)_p->vpu.count=_nc;\
1613 static inline void r300SetupVertexProgramFragment(r300ContextPtr r300
, int dest
, struct r300_vertex_shader_fragment
*vsf
)
1617 if (vsf
->length
== 0)
1620 if (vsf
->length
& 0x3) {
1621 fprintf(stderr
, "VERTEX_SHADER_FRAGMENT must have length divisible by 4\n");
1625 switch ((dest
>> 8) & 0xf) {
1627 R300_STATECHANGE(r300
, vpi
);
1628 for (i
= 0; i
< vsf
->length
; i
++)
1629 r300
->hw
.vpi
.cmd
[R300_VPI_INSTR_0
+ i
+ 4 * (dest
& 0xff)] = (vsf
->body
.d
[i
]);
1630 bump_vpu_count(r300
->hw
.vpi
.cmd
, vsf
->length
+ 4 * (dest
& 0xff));
1634 R300_STATECHANGE(r300
, vpp
);
1635 for (i
= 0; i
< vsf
->length
; i
++)
1636 r300
->hw
.vpp
.cmd
[R300_VPP_PARAM_0
+ i
+ 4 * (dest
& 0xff)] = (vsf
->body
.d
[i
]);
1637 bump_vpu_count(r300
->hw
.vpp
.cmd
, vsf
->length
+ 4 * (dest
& 0xff));
1640 R300_STATECHANGE(r300
, vps
);
1641 for (i
= 0; i
< vsf
->length
; i
++)
1642 r300
->hw
.vps
.cmd
[1 + i
+ 4 * (dest
& 0xff)] = (vsf
->body
.d
[i
]);
1643 bump_vpu_count(r300
->hw
.vps
.cmd
, vsf
->length
+ 4 * (dest
& 0xff));
1646 fprintf(stderr
, "%s:%s don't know how to handle dest %04x\n", __FILE__
, __FUNCTION__
, dest
);
1651 static void r300SetupDefaultVertexProgram(r300ContextPtr rmesa
)
1653 struct r300_vertex_shader_state
*prog
= &(rmesa
->state
.vertex_shader
);
1657 int param_count
= 0;
1658 int program_end
= 0;
1660 for (i
= VERT_ATTRIB_POS
; i
< VERT_ATTRIB_MAX
; i
++) {
1661 if (rmesa
->state
.sw_tcl_inputs
[i
] != -1) {
1662 prog
->program
.body
.i
[program_end
+ 0] = EASY_VSF_OP(MUL
, o_reg
++, ALL
, RESULT
);
1663 prog
->program
.body
.i
[program_end
+ 1] = VSF_REG(rmesa
->state
.sw_tcl_inputs
[i
]);
1664 prog
->program
.body
.i
[program_end
+ 2] = VSF_ATTR_UNITY(rmesa
->state
.sw_tcl_inputs
[i
]);
1665 prog
->program
.body
.i
[program_end
+ 3] = VSF_UNITY(rmesa
->state
.sw_tcl_inputs
[i
]);
1670 prog
->program
.length
= program_end
;
1672 r300SetupVertexProgramFragment(rmesa
, R300_PVS_UPLOAD_PROGRAM
,
1674 inst_count
= (prog
->program
.length
/ 4) - 1;
1676 R300_STATECHANGE(rmesa
, pvs
);
1677 rmesa
->hw
.pvs
.cmd
[R300_PVS_CNTL_1
] =
1678 (0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT
) |
1679 (inst_count
<< R300_PVS_CNTL_1_POS_END_SHIFT
) |
1680 (inst_count
<< R300_PVS_CNTL_1_PROGRAM_END_SHIFT
);
1681 rmesa
->hw
.pvs
.cmd
[R300_PVS_CNTL_2
] =
1682 (0 << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT
) |
1683 (param_count
<< R300_PVS_CNTL_2_PARAM_COUNT_SHIFT
);
1684 rmesa
->hw
.pvs
.cmd
[R300_PVS_CNTL_3
] =
1685 (inst_count
<< R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT
) |
1686 (inst_count
<< R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT
);
1689 static void r300SetupRealVertexProgram(r300ContextPtr rmesa
)
1691 GLcontext
*ctx
= rmesa
->radeon
.glCtx
;
1692 struct r300_vertex_program
*prog
= (struct r300_vertex_program
*)CURRENT_VERTEX_SHADER(ctx
);
1694 int param_count
= 0;
1696 /* FIXME: r300SetupVertexProgramFragment */
1697 R300_STATECHANGE(rmesa
, vpp
);
1699 r300VertexProgUpdateParams(ctx
,
1700 (struct r300_vertex_program_cont
*)
1701 ctx
->VertexProgram
._Current
,
1702 (float *)&rmesa
->hw
.vpp
.
1703 cmd
[R300_VPP_PARAM_0
]);
1704 bump_vpu_count(rmesa
->hw
.vpp
.cmd
, param_count
);
1707 r300SetupVertexProgramFragment(rmesa
, R300_PVS_UPLOAD_PROGRAM
, &(prog
->program
));
1708 inst_count
= (prog
->program
.length
/ 4) - 1;
1710 R300_STATECHANGE(rmesa
, pvs
);
1711 rmesa
->hw
.pvs
.cmd
[R300_PVS_CNTL_1
] =
1712 (0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT
) |
1713 (inst_count
<< R300_PVS_CNTL_1_POS_END_SHIFT
) |
1714 (inst_count
<< R300_PVS_CNTL_1_PROGRAM_END_SHIFT
);
1715 rmesa
->hw
.pvs
.cmd
[R300_PVS_CNTL_2
] =
1716 (0 << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT
) |
1717 (param_count
<< R300_PVS_CNTL_2_PARAM_COUNT_SHIFT
);
1718 rmesa
->hw
.pvs
.cmd
[R300_PVS_CNTL_3
] =
1719 (inst_count
<< R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT
) |
1720 (inst_count
<< R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT
);
1723 static void r300SetupVertexProgram(r300ContextPtr rmesa
)
1725 GLcontext
*ctx
= rmesa
->radeon
.glCtx
;
1727 /* Reset state, in case we don't use something */
1728 ((drm_r300_cmd_header_t
*) rmesa
->hw
.vpp
.cmd
)->vpu
.count
= 0;
1729 ((drm_r300_cmd_header_t
*) rmesa
->hw
.vpi
.cmd
)->vpu
.count
= 0;
1730 ((drm_r300_cmd_header_t
*) rmesa
->hw
.vps
.cmd
)->vpu
.count
= 0;
1732 /* Not sure why this doesnt work...
1733 0x400 area might have something to do with pixel shaders as it appears right after pfs programming.
1734 0x406 is set to { 0.0, 0.0, 1.0, 0.0 } most of the time but should change with smooth points and in other rare cases. */
1735 //setup_vertex_shader_fragment(rmesa, 0x406, &unk4);
1736 if (hw_tcl_on
&& ((struct r300_vertex_program
*)CURRENT_VERTEX_SHADER(ctx
))->translated
) {
1737 r300SetupRealVertexProgram(rmesa
);
1739 /* FIXME: This needs to be replaced by vertex shader generation code. */
1740 r300SetupDefaultVertexProgram(rmesa
);
1744 /* FIXME: This is done for vertex shader fragments, but also needs to be
1745 * done for vap_pvs, so I leave it as a reminder. */
1747 reg_start(R300_VAP_PVS_WAITIDLE
, 0);
1753 * Enable/Disable states.
1755 * \note Mesa already filters redundant calls to this function.
1757 static void r300Enable(GLcontext
* ctx
, GLenum cap
, GLboolean state
)
1759 if (RADEON_DEBUG
& DEBUG_STATE
)
1760 fprintf(stderr
, "%s( %s = %s )\n", __FUNCTION__
,
1761 _mesa_lookup_enum_by_nr(cap
),
1762 state
? "GL_TRUE" : "GL_FALSE");
1771 r300SetFogState(ctx
, state
);
1774 r300SetAlphaState(ctx
);
1777 case GL_COLOR_LOGIC_OP
:
1778 r300SetBlendState(ctx
);
1780 case GL_CLIP_PLANE0
:
1781 case GL_CLIP_PLANE1
:
1782 case GL_CLIP_PLANE2
:
1783 case GL_CLIP_PLANE3
:
1784 case GL_CLIP_PLANE4
:
1785 case GL_CLIP_PLANE5
:
1786 r300SetClipPlaneState(ctx
, cap
, state
);
1789 r300SetDepthState(ctx
);
1791 case GL_STENCIL_TEST
:
1792 r300SetStencilState(ctx
, state
);
1795 r300UpdateCulling(ctx
);
1797 case GL_POLYGON_OFFSET_POINT
:
1798 case GL_POLYGON_OFFSET_LINE
:
1799 case GL_POLYGON_OFFSET_FILL
:
1800 r300SetPolygonOffsetState(ctx
, state
);
1803 radeonEnable(ctx
, cap
, state
);
1809 * Completely recalculates hardware state based on the Mesa state.
1811 static void r300ResetHwState(r300ContextPtr r300
)
1813 GLcontext
*ctx
= r300
->radeon
.glCtx
;
1816 if (!(r300
->radeon
.radeonScreen
->chip_flags
& RADEON_CHIPSET_TCL
))
1819 if (RADEON_DEBUG
& DEBUG_STATE
)
1820 fprintf(stderr
, "%s\n", __FUNCTION__
);
1822 r300UpdateWindow(ctx
);
1825 ctx
->Color
.ColorMask
[RCOMP
],
1826 ctx
->Color
.ColorMask
[GCOMP
],
1827 ctx
->Color
.ColorMask
[BCOMP
], ctx
->Color
.ColorMask
[ACOMP
]);
1829 r300Enable(ctx
, GL_DEPTH_TEST
, ctx
->Depth
.Test
);
1830 r300DepthMask(ctx
, ctx
->Depth
.Mask
);
1831 r300DepthFunc(ctx
, ctx
->Depth
.Func
);
1834 r300Enable(ctx
, GL_STENCIL_TEST
, ctx
->Stencil
.Enabled
);
1835 r300StencilMaskSeparate(ctx
, 0, ctx
->Stencil
.WriteMask
[0]);
1836 r300StencilFuncSeparate(ctx
, 0, ctx
->Stencil
.Function
[0],
1837 ctx
->Stencil
.Ref
[0], ctx
->Stencil
.ValueMask
[0]);
1838 r300StencilOpSeparate(ctx
, 0, ctx
->Stencil
.FailFunc
[0],
1839 ctx
->Stencil
.ZFailFunc
[0],
1840 ctx
->Stencil
.ZPassFunc
[0]);
1842 r300UpdateCulling(ctx
);
1844 r300UpdateTextureState(ctx
);
1846 r300SetBlendState(ctx
);
1848 r300AlphaFunc(ctx
, ctx
->Color
.AlphaFunc
, ctx
->Color
.AlphaRef
);
1849 r300Enable(ctx
, GL_ALPHA_TEST
, ctx
->Color
.AlphaEnabled
);
1852 r300
->hw
.vap_cntl
.cmd
[1] = 0x0014045a;
1854 r300
->hw
.vap_cntl
.cmd
[1] = 0x0030045A; //0x0030065a /* Dangerous */
1856 r300
->hw
.vte
.cmd
[1] = R300_VPORT_X_SCALE_ENA
1857 | R300_VPORT_X_OFFSET_ENA
1858 | R300_VPORT_Y_SCALE_ENA
1859 | R300_VPORT_Y_OFFSET_ENA
1860 | R300_VPORT_Z_SCALE_ENA
1861 | R300_VPORT_Z_OFFSET_ENA
| R300_VTX_W0_FMT
;
1862 r300
->hw
.vte
.cmd
[2] = 0x00000008;
1864 r300
->hw
.vap_vf_max_vtx_indx
.cmd
[1] = 0x00FFFFFF;
1865 r300
->hw
.vap_vf_max_vtx_indx
.cmd
[2] = 0x00000000;
1867 #ifdef MESA_LITTLE_ENDIAN
1868 r300
->hw
.vap_cntl_status
.cmd
[1] = R300_VC_NO_SWAP
;
1870 r300
->hw
.vap_cntl_status
.cmd
[1] = R300_VC_32BIT_SWAP
;
1873 /* disable VAP/TCL on non-TCL capable chips */
1875 r300
->hw
.vap_cntl_status
.cmd
[1] |= R300_VAP_TCL_BYPASS
;
1877 r300
->hw
.vap_psc_sgn_norm_cntl
.cmd
[1] = 0xAAAAAAAA;
1879 /* XXX: Other families? */
1881 r300
->hw
.vap_clip_cntl
.cmd
[1] = R300_221C_NORMAL
;
1883 r300
->hw
.vap_clip
.cmd
[1] = r300PackFloat32(1.0); /* X */
1884 r300
->hw
.vap_clip
.cmd
[2] = r300PackFloat32(1.0); /* X */
1885 r300
->hw
.vap_clip
.cmd
[3] = r300PackFloat32(1.0); /* Y */
1886 r300
->hw
.vap_clip
.cmd
[4] = r300PackFloat32(1.0); /* Y */
1888 switch (r300
->radeon
.radeonScreen
->chip_family
) {
1889 case CHIP_FAMILY_R300
:
1890 r300
->hw
.vap_pvs_vtx_timeout_reg
.cmd
[1] = R300_2288_R300
;
1893 r300
->hw
.vap_pvs_vtx_timeout_reg
.cmd
[1] = R300_2288_RV350
;
1898 r300
->hw
.gb_enable
.cmd
[1] = R300_GB_POINT_STUFF_ENABLE
1899 | R300_GB_LINE_STUFF_ENABLE
1900 | R300_GB_TRIANGLE_STUFF_ENABLE
;
1902 r300
->hw
.gb_misc
.cmd
[R300_GB_MISC_MSPOS_0
] = 0x66666666;
1903 r300
->hw
.gb_misc
.cmd
[R300_GB_MISC_MSPOS_1
] = 0x06666666;
1905 /* XXX: Other families? */
1906 r300
->hw
.gb_misc
.cmd
[R300_GB_MISC_TILE_CONFIG
] =
1907 R300_GB_TILE_ENABLE
| R300_GB_TILE_SIZE_16
;
1908 switch (r300
->radeon
.radeonScreen
->chip_family
) {
1909 case CHIP_FAMILY_R300
:
1910 case CHIP_FAMILY_R350
:
1911 case CHIP_FAMILY_RV410
:
1912 r300
->hw
.gb_misc
.cmd
[R300_GB_MISC_TILE_CONFIG
] |=
1913 R300_GB_TILE_PIPE_COUNT_R300
;
1915 case CHIP_FAMILY_R420
:
1916 r300
->hw
.gb_misc
.cmd
[R300_GB_MISC_TILE_CONFIG
] |=
1917 R300_GB_TILE_PIPE_COUNT_R420
;
1920 r300
->hw
.gb_misc
.cmd
[R300_GB_MISC_TILE_CONFIG
] |=
1921 R300_GB_TILE_DISABLE
; /* TODO: This disables tiling totally. I guess it happened accidentially. */
1925 /* XXX: set to 0 when fog is disabled? */
1926 r300
->hw
.gb_misc
.cmd
[R300_GB_MISC_SELECT
] = R300_GB_FOG_SELECT_1_1_W
;
1928 /* XXX: Enable anti-aliasing? */
1929 r300
->hw
.gb_misc
.cmd
[R300_GB_MISC_AA_CONFIG
] = GB_AA_CONFIG_AA_DISABLE
;
1931 r300
->hw
.ga_point_s0
.cmd
[1] = r300PackFloat32(0.0);
1932 r300
->hw
.ga_point_s0
.cmd
[2] = r300PackFloat32(0.0);
1933 r300
->hw
.ga_point_s0
.cmd
[3] = r300PackFloat32(1.0);
1934 r300
->hw
.ga_point_s0
.cmd
[4] = r300PackFloat32(1.0);
1936 r300
->hw
.ga_triangle_stipple
.cmd
[1] = 0x00050005;
1938 r300PointSize(ctx
, 1.0);
1940 r300
->hw
.ga_point_minmax
.cmd
[1] = 0x18000006;
1941 r300
->hw
.ga_point_minmax
.cmd
[2] = 0x00020006;
1942 r300
->hw
.ga_point_minmax
.cmd
[3] = r300PackFloat32(1.0 / 192.0);
1944 r300LineWidth(ctx
, 1.0);
1946 r300
->hw
.ga_line_stipple
.cmd
[1] = 0;
1947 r300
->hw
.ga_line_stipple
.cmd
[2] = r300PackFloat32(0.0);
1948 r300
->hw
.ga_line_stipple
.cmd
[3] = r300PackFloat32(1.0);
1950 r300ShadeModel(ctx
, ctx
->Light
.ShadeModel
);
1952 r300PolygonMode(ctx
, GL_FRONT
, ctx
->Polygon
.FrontMode
);
1953 r300PolygonMode(ctx
, GL_BACK
, ctx
->Polygon
.BackMode
);
1954 r300
->hw
.zbias_cntl
.cmd
[1] = 0x00000000;
1956 r300PolygonOffset(ctx
, ctx
->Polygon
.OffsetFactor
,
1957 ctx
->Polygon
.OffsetUnits
);
1958 r300Enable(ctx
, GL_POLYGON_OFFSET_POINT
, ctx
->Polygon
.OffsetPoint
);
1959 r300Enable(ctx
, GL_POLYGON_OFFSET_LINE
, ctx
->Polygon
.OffsetLine
);
1960 r300Enable(ctx
, GL_POLYGON_OFFSET_FILL
, ctx
->Polygon
.OffsetFill
);
1962 r300
->hw
.su_depth_scale
.cmd
[1] = 0x4B7FFFFF;
1963 r300
->hw
.su_depth_scale
.cmd
[2] = 0x00000000;
1965 r300
->hw
.sc_hyperz
.cmd
[1] = 0x0000001C;
1966 r300
->hw
.sc_hyperz
.cmd
[2] = 0x2DA49525;
1968 r300
->hw
.sc_screendoor
.cmd
[1] = 0x00FFFFFF;
1970 r300
->hw
.us_out_fmt
.cmd
[1] = 0x00001B01;
1971 r300
->hw
.us_out_fmt
.cmd
[2] = 0x00001B0F;
1972 r300
->hw
.us_out_fmt
.cmd
[3] = 0x00001B0F;
1973 r300
->hw
.us_out_fmt
.cmd
[4] = 0x00001B0F;
1974 r300
->hw
.us_out_fmt
.cmd
[5] = 0x00000001;
1976 r300Enable(ctx
, GL_FOG
, ctx
->Fog
.Enabled
);
1977 r300Fogfv(ctx
, GL_FOG_MODE
, NULL
);
1978 r300Fogfv(ctx
, GL_FOG_DENSITY
, &ctx
->Fog
.Density
);
1979 r300Fogfv(ctx
, GL_FOG_START
, &ctx
->Fog
.Start
);
1980 r300Fogfv(ctx
, GL_FOG_END
, &ctx
->Fog
.End
);
1981 r300Fogfv(ctx
, GL_FOG_COLOR
, ctx
->Fog
.Color
);
1982 r300Fogfv(ctx
, GL_FOG_COORDINATE_SOURCE_EXT
, NULL
);
1984 r300
->hw
.fg_depth_src
.cmd
[1] = 0;
1986 r300
->hw
.rb3d_cctl
.cmd
[1] = 0;
1988 r300BlendColor(ctx
, ctx
->Color
.BlendColor
);
1990 /* Again, r300ClearBuffer uses this */
1991 r300
->hw
.cb
.cmd
[R300_CB_OFFSET
] =
1992 r300
->radeon
.state
.color
.drawOffset
+
1993 r300
->radeon
.radeonScreen
->fbLocation
;
1994 r300
->hw
.cb
.cmd
[R300_CB_PITCH
] = r300
->radeon
.state
.color
.drawPitch
;
1996 if (r300
->radeon
.radeonScreen
->cpp
== 4)
1997 r300
->hw
.cb
.cmd
[R300_CB_PITCH
] |= R300_COLOR_FORMAT_ARGB8888
;
1999 r300
->hw
.cb
.cmd
[R300_CB_PITCH
] |= R300_COLOR_FORMAT_RGB565
;
2001 if (r300
->radeon
.sarea
->tiling_enabled
)
2002 r300
->hw
.cb
.cmd
[R300_CB_PITCH
] |= R300_COLOR_TILE_ENABLE
;
2004 r300
->hw
.rb3d_dither_ctl
.cmd
[1] = 0;
2005 r300
->hw
.rb3d_dither_ctl
.cmd
[2] = 0;
2006 r300
->hw
.rb3d_dither_ctl
.cmd
[3] = 0;
2007 r300
->hw
.rb3d_dither_ctl
.cmd
[4] = 0;
2008 r300
->hw
.rb3d_dither_ctl
.cmd
[5] = 0;
2009 r300
->hw
.rb3d_dither_ctl
.cmd
[6] = 0;
2010 r300
->hw
.rb3d_dither_ctl
.cmd
[7] = 0;
2011 r300
->hw
.rb3d_dither_ctl
.cmd
[8] = 0;
2012 r300
->hw
.rb3d_dither_ctl
.cmd
[9] = 0;
2014 r300
->hw
.rb3d_aaresolve_ctl
.cmd
[1] = 0;
2016 r300
->hw
.rb3d_discard_src_pixel_lte_threshold
.cmd
[1] = 0x00000000;
2017 r300
->hw
.rb3d_discard_src_pixel_lte_threshold
.cmd
[2] = 0xffffffff;
2019 r300
->hw
.zb
.cmd
[R300_ZB_OFFSET
] =
2020 r300
->radeon
.radeonScreen
->depthOffset
+
2021 r300
->radeon
.radeonScreen
->fbLocation
;
2022 r300
->hw
.zb
.cmd
[R300_ZB_PITCH
] = r300
->radeon
.radeonScreen
->depthPitch
;
2024 if (r300
->radeon
.sarea
->tiling_enabled
) {
2025 /* XXX: Turn off when clearing buffers ? */
2026 r300
->hw
.zb
.cmd
[R300_ZB_PITCH
] |= ZB_DEPTHPITCH_DEPTHMACROTILE_ENABLE
;
2028 if (ctx
->Visual
.depthBits
== 24)
2029 r300
->hw
.zb
.cmd
[R300_ZB_PITCH
] |=
2030 ZB_DEPTHPITCH_DEPTHMICROTILE_TILED
;
2033 r300
->hw
.zb_depthclearvalue
.cmd
[1] = 0;
2035 r300
->hw
.unk4F30
.cmd
[1] = 0;
2036 r300
->hw
.unk4F30
.cmd
[2] = 0;
2038 r300
->hw
.zb_hiz_offset
.cmd
[1] = 0;
2040 r300
->hw
.zb_hiz_pitch
.cmd
[1] = 0;
2043 r300
->hw
.vps
.cmd
[R300_VPS_ZERO_0
] = 0;
2044 r300
->hw
.vps
.cmd
[R300_VPS_ZERO_1
] = 0;
2045 r300
->hw
.vps
.cmd
[R300_VPS_POINTSIZE
] = r300PackFloat32(1.0);
2046 r300
->hw
.vps
.cmd
[R300_VPS_ZERO_3
] = 0;
2049 r300
->hw
.all_dirty
= GL_TRUE
;
2052 void r300UpdateShaders(r300ContextPtr rmesa
)
2055 struct r300_vertex_program
*vp
;
2058 ctx
= rmesa
->radeon
.glCtx
;
2060 if (rmesa
->NewGLState
&& hw_tcl_on
) {
2061 rmesa
->NewGLState
= 0;
2063 for (i
= _TNL_FIRST_MAT
; i
<= _TNL_LAST_MAT
; i
++) {
2064 rmesa
->temp_attrib
[i
] =
2065 TNL_CONTEXT(ctx
)->vb
.AttribPtr
[i
];
2066 TNL_CONTEXT(ctx
)->vb
.AttribPtr
[i
] =
2067 &rmesa
->dummy_attrib
[i
];
2070 _tnl_UpdateFixedFunctionProgram(ctx
);
2072 for (i
= _TNL_FIRST_MAT
; i
<= _TNL_LAST_MAT
; i
++) {
2073 TNL_CONTEXT(ctx
)->vb
.AttribPtr
[i
] =
2074 rmesa
->temp_attrib
[i
];
2077 r300SelectVertexShader(rmesa
);
2078 vp
= (struct r300_vertex_program
*)
2079 CURRENT_VERTEX_SHADER(ctx
);
2080 /*if (vp->translated == GL_FALSE)
2081 r300TranslateVertexShader(vp); */
2082 if (vp
->translated
== GL_FALSE
) {
2083 fprintf(stderr
, "Failing back to sw-tcl\n");
2084 hw_tcl_on
= future_hw_tcl_on
= 0;
2085 r300ResetHwState(rmesa
);
2089 r300UpdateStateParameters(ctx
, _NEW_PROGRAM
);
2093 static void r300SetupPixelShader(r300ContextPtr rmesa
)
2095 GLcontext
*ctx
= rmesa
->radeon
.glCtx
;
2096 struct r300_fragment_program
*fp
= (struct r300_fragment_program
*)
2097 (char *)ctx
->FragmentProgram
._Current
;
2100 if (!fp
) /* should only happenen once, just after context is created */
2103 r300TranslateFragmentShader(rmesa
, fp
);
2104 if (!fp
->translated
) {
2105 fprintf(stderr
, "%s: No valid fragment shader, exiting\n",
2110 R300_STATECHANGE(rmesa
, fpi
[0]);
2111 rmesa
->hw
.fpi
[0].cmd
[R300_FPI_CMD_0
] = cmdpacket0(R300_PFS_INSTR0_0
, fp
->alu_end
+ 1);
2112 for (i
= 0; i
<= fp
->alu_end
; i
++) {
2113 rmesa
->hw
.fpi
[0].cmd
[R300_FPI_INSTR_0
+ i
] = fp
->alu
.inst
[i
].inst0
;
2116 R300_STATECHANGE(rmesa
, fpi
[1]);
2117 rmesa
->hw
.fpi
[1].cmd
[R300_FPI_CMD_0
] = cmdpacket0(R300_PFS_INSTR1_0
, fp
->alu_end
+ 1);
2118 for (i
= 0; i
<= fp
->alu_end
; i
++) {
2119 rmesa
->hw
.fpi
[1].cmd
[R300_FPI_INSTR_0
+ i
] = fp
->alu
.inst
[i
].inst1
;
2122 R300_STATECHANGE(rmesa
, fpi
[2]);
2123 rmesa
->hw
.fpi
[2].cmd
[R300_FPI_CMD_0
] = cmdpacket0(R300_PFS_INSTR2_0
, fp
->alu_end
+ 1);
2124 for (i
= 0; i
<= fp
->alu_end
; i
++) {
2125 rmesa
->hw
.fpi
[2].cmd
[R300_FPI_INSTR_0
+ i
] = fp
->alu
.inst
[i
].inst2
;
2128 R300_STATECHANGE(rmesa
, fpi
[3]);
2129 rmesa
->hw
.fpi
[3].cmd
[R300_FPI_CMD_0
] = cmdpacket0(R300_PFS_INSTR3_0
, fp
->alu_end
+ 1);
2130 for (i
= 0; i
<= fp
->alu_end
; i
++) {
2131 rmesa
->hw
.fpi
[3].cmd
[R300_FPI_INSTR_0
+ i
] = fp
->alu
.inst
[i
].inst3
;
2134 R300_STATECHANGE(rmesa
, fp
);
2135 rmesa
->hw
.fp
.cmd
[R300_FP_CNTL0
] = fp
->cur_node
| (fp
->first_node_has_tex
<< 3);
2136 rmesa
->hw
.fp
.cmd
[R300_FP_CNTL1
] = fp
->max_temp_idx
;
2137 rmesa
->hw
.fp
.cmd
[R300_FP_CNTL2
] =
2138 (fp
->alu_offset
<< R300_PFS_CNTL_ALU_OFFSET_SHIFT
) |
2139 (fp
->alu_end
<< R300_PFS_CNTL_ALU_END_SHIFT
) |
2140 (fp
->tex_offset
<< R300_PFS_CNTL_TEX_OFFSET_SHIFT
) |
2141 (fp
->tex_end
<< R300_PFS_CNTL_TEX_END_SHIFT
);
2142 /* I just want to say, the way these nodes are stored.. weird.. */
2143 for (i
= 0, k
= (4 - (fp
->cur_node
+ 1)); i
< 4; i
++, k
++) {
2144 if (i
< (fp
->cur_node
+ 1)) {
2145 rmesa
->hw
.fp
.cmd
[R300_FP_NODE0
+ k
] =
2146 (fp
->node
[i
].alu_offset
<< R300_PFS_NODE_ALU_OFFSET_SHIFT
) |
2147 (fp
->node
[i
].alu_end
<< R300_PFS_NODE_ALU_END_SHIFT
) |
2148 (fp
->node
[i
].tex_offset
<< R300_PFS_NODE_TEX_OFFSET_SHIFT
) |
2149 (fp
->node
[i
].tex_end
<< R300_PFS_NODE_TEX_END_SHIFT
) |
2152 rmesa
->hw
.fp
.cmd
[R300_FP_NODE0
+ (3 - i
)] = 0;
2156 R300_STATECHANGE(rmesa
, fpp
);
2157 rmesa
->hw
.fpp
.cmd
[R300_FPP_CMD_0
] = cmdpacket0(R300_PFS_PARAM_0_X
, fp
->const_nr
* 4);
2158 for (i
= 0; i
< fp
->const_nr
; i
++) {
2159 rmesa
->hw
.fpp
.cmd
[R300_FPP_PARAM_0
+ 4 * i
+ 0] = r300PackFloat24(fp
->constant
[i
][0]);
2160 rmesa
->hw
.fpp
.cmd
[R300_FPP_PARAM_0
+ 4 * i
+ 1] = r300PackFloat24(fp
->constant
[i
][1]);
2161 rmesa
->hw
.fpp
.cmd
[R300_FPP_PARAM_0
+ 4 * i
+ 2] = r300PackFloat24(fp
->constant
[i
][2]);
2162 rmesa
->hw
.fpp
.cmd
[R300_FPP_PARAM_0
+ 4 * i
+ 3] = r300PackFloat24(fp
->constant
[i
][3]);
2166 void r300UpdateShaderStates(r300ContextPtr rmesa
)
2169 ctx
= rmesa
->radeon
.glCtx
;
2171 r300UpdateTextureState(ctx
);
2173 r300SetupPixelShader(rmesa
);
2174 r300SetupTextures(ctx
);
2176 if ((rmesa
->radeon
.radeonScreen
->chip_flags
& RADEON_CHIPSET_TCL
))
2177 r300SetupVertexProgram(rmesa
);
2178 r300SetupRSUnit(ctx
);
2182 * Called by Mesa after an internal state update.
2184 static void r300InvalidateState(GLcontext
* ctx
, GLuint new_state
)
2186 r300ContextPtr r300
= R300_CONTEXT(ctx
);
2188 _swrast_InvalidateState(ctx
, new_state
);
2189 _swsetup_InvalidateState(ctx
, new_state
);
2190 _vbo_InvalidateState(ctx
, new_state
);
2191 _tnl_InvalidateState(ctx
, new_state
);
2192 _ae_invalidate_state(ctx
, new_state
);
2194 if (new_state
& (_NEW_BUFFERS
| _NEW_COLOR
| _NEW_PIXEL
)) {
2195 r300UpdateDrawBuffer(ctx
);
2198 r300UpdateStateParameters(ctx
, new_state
);
2200 r300
->NewGLState
|= new_state
;
2204 * Calculate initial hardware state and register state functions.
2205 * Assumes that the command buffer and state atoms have been
2206 * initialized already.
2208 void r300InitState(r300ContextPtr r300
)
2210 GLcontext
*ctx
= r300
->radeon
.glCtx
;
2213 radeonInitState(&r300
->radeon
);
2215 switch (ctx
->Visual
.depthBits
) {
2217 r300
->state
.depth
.scale
= 1.0 / (GLfloat
) 0xffff;
2218 depth_fmt
= ZB_FORMAR_DEPTHFORMAT_16BIT_INT_Z
;
2219 r300
->state
.stencil
.clear
= 0x00000000;
2222 r300
->state
.depth
.scale
= 1.0 / (GLfloat
) 0xffffff;
2223 depth_fmt
= ZB_FORMAR_DEPTHFORMAT_24BIT_INT_Z
;
2224 r300
->state
.stencil
.clear
= 0x00ff0000;
2227 fprintf(stderr
, "Error: Unsupported depth %d... exiting\n",
2228 ctx
->Visual
.depthBits
);
2232 /* Only have hw stencil when depth buffer is 24 bits deep */
2233 r300
->state
.stencil
.hw_stencil
= (ctx
->Visual
.stencilBits
> 0 &&
2234 ctx
->Visual
.depthBits
== 24);
2236 memset(&(r300
->state
.texture
), 0, sizeof(r300
->state
.texture
));
2238 r300ResetHwState(r300
);
2241 static void r300RenderMode(GLcontext
* ctx
, GLenum mode
)
2243 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
2248 void r300UpdateClipPlanes( GLcontext
*ctx
)
2250 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
2253 for (p
= 0; p
< ctx
->Const
.MaxClipPlanes
; p
++) {
2254 if (ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) {
2255 GLint
*ip
= (GLint
*)ctx
->Transform
._ClipUserPlane
[p
];
2257 R300_STATECHANGE( rmesa
, vpucp
[p
] );
2258 rmesa
->hw
.vpucp
[p
].cmd
[R300_VPUCP_X
] = ip
[0];
2259 rmesa
->hw
.vpucp
[p
].cmd
[R300_VPUCP_Y
] = ip
[1];
2260 rmesa
->hw
.vpucp
[p
].cmd
[R300_VPUCP_Z
] = ip
[2];
2261 rmesa
->hw
.vpucp
[p
].cmd
[R300_VPUCP_W
] = ip
[3];
2267 * Initialize driver's state callback functions
2269 void r300InitStateFuncs(struct dd_function_table
*functions
)
2271 radeonInitStateFuncs(functions
);
2273 functions
->UpdateState
= r300InvalidateState
;
2274 functions
->AlphaFunc
= r300AlphaFunc
;
2275 functions
->BlendColor
= r300BlendColor
;
2276 functions
->BlendEquationSeparate
= r300BlendEquationSeparate
;
2277 functions
->BlendFuncSeparate
= r300BlendFuncSeparate
;
2278 functions
->Enable
= r300Enable
;
2279 functions
->ColorMask
= r300ColorMask
;
2280 functions
->DepthFunc
= r300DepthFunc
;
2281 functions
->DepthMask
= r300DepthMask
;
2282 functions
->CullFace
= r300CullFace
;
2283 functions
->Fogfv
= r300Fogfv
;
2284 functions
->FrontFace
= r300FrontFace
;
2285 functions
->ShadeModel
= r300ShadeModel
;
2287 /* Stencil related */
2288 functions
->ClearStencil
= r300ClearStencil
;
2289 functions
->StencilFuncSeparate
= r300StencilFuncSeparate
;
2290 functions
->StencilMaskSeparate
= r300StencilMaskSeparate
;
2291 functions
->StencilOpSeparate
= r300StencilOpSeparate
;
2293 /* Viewport related */
2294 functions
->Viewport
= r300Viewport
;
2295 functions
->DepthRange
= r300DepthRange
;
2296 functions
->PointSize
= r300PointSize
;
2297 functions
->LineWidth
= r300LineWidth
;
2299 functions
->PolygonOffset
= r300PolygonOffset
;
2300 functions
->PolygonMode
= r300PolygonMode
;
2302 functions
->RenderMode
= r300RenderMode
;
2304 functions
->ClipPlane
= r300ClipPlane
;