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
);
70 static void r300ClipPlane( GLcontext
*ctx
, GLenum plane
, const GLfloat
*eq
);
72 static void r300BlendColor(GLcontext
* ctx
, const GLfloat cf
[4])
75 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
77 R300_STATECHANGE(rmesa
, blend_color
);
79 CLAMPED_FLOAT_TO_UBYTE(color
[0], cf
[0]);
80 CLAMPED_FLOAT_TO_UBYTE(color
[1], cf
[1]);
81 CLAMPED_FLOAT_TO_UBYTE(color
[2], cf
[2]);
82 CLAMPED_FLOAT_TO_UBYTE(color
[3], cf
[3]);
84 rmesa
->hw
.blend_color
.cmd
[1] = PACK_COLOR_8888(color
[3], color
[0],
86 rmesa
->hw
.blend_color
.cmd
[2] = 0;
87 rmesa
->hw
.blend_color
.cmd
[3] = 0;
91 * Calculate the hardware blend factor setting. This same function is used
92 * for source and destination of both alpha and RGB.
95 * The hardware register value for the specified blend factor. This value
96 * will need to be shifted into the correct position for either source or
100 * Since the two cases where source and destination are handled differently
101 * are essentially error cases, they should never happen. Determine if these
102 * cases can be removed.
104 static int blend_factor(GLenum factor
, GLboolean is_src
)
108 return R300_BLEND_GL_ZERO
;
111 return R300_BLEND_GL_ONE
;
114 return R300_BLEND_GL_DST_COLOR
;
116 case GL_ONE_MINUS_DST_COLOR
:
117 return R300_BLEND_GL_ONE_MINUS_DST_COLOR
;
120 return R300_BLEND_GL_SRC_COLOR
;
122 case GL_ONE_MINUS_SRC_COLOR
:
123 return R300_BLEND_GL_ONE_MINUS_SRC_COLOR
;
126 return R300_BLEND_GL_SRC_ALPHA
;
128 case GL_ONE_MINUS_SRC_ALPHA
:
129 return R300_BLEND_GL_ONE_MINUS_SRC_ALPHA
;
132 return R300_BLEND_GL_DST_ALPHA
;
134 case GL_ONE_MINUS_DST_ALPHA
:
135 return R300_BLEND_GL_ONE_MINUS_DST_ALPHA
;
137 case GL_SRC_ALPHA_SATURATE
:
138 return (is_src
) ? R300_BLEND_GL_SRC_ALPHA_SATURATE
:
141 case GL_CONSTANT_COLOR
:
142 return R300_BLEND_GL_CONST_COLOR
;
144 case GL_ONE_MINUS_CONSTANT_COLOR
:
145 return R300_BLEND_GL_ONE_MINUS_CONST_COLOR
;
147 case GL_CONSTANT_ALPHA
:
148 return R300_BLEND_GL_CONST_ALPHA
;
150 case GL_ONE_MINUS_CONSTANT_ALPHA
:
151 return R300_BLEND_GL_ONE_MINUS_CONST_ALPHA
;
154 fprintf(stderr
, "unknown blend factor %x\n", factor
);
155 return (is_src
) ? R300_BLEND_GL_ONE
: R300_BLEND_GL_ZERO
;
161 * Sets both the blend equation and the blend function.
162 * This is done in a single
163 * function because some blend equations (i.e., \c GL_MIN and \c GL_MAX)
164 * change the interpretation of the blend function.
165 * Also, make sure that blend function and blend equation are set to their
166 * default value if color blending is not enabled, since at least blend
167 * equations GL_MIN and GL_FUNC_REVERSE_SUBTRACT will cause wrong results
168 * otherwise for unknown reasons.
171 /* helper function */
172 static void r300SetBlendCntl(r300ContextPtr r300
, int func
, int eqn
,
173 int cbits
, int funcA
, int eqnA
)
175 GLuint new_ablend
, new_cblend
;
179 "eqnA=%08x funcA=%08x eqn=%08x func=%08x cbits=%08x\n",
180 eqnA
, funcA
, eqn
, func
, cbits
);
182 new_ablend
= eqnA
| funcA
;
183 new_cblend
= eqn
| func
;
185 /* Some blend factor combinations don't seem to work when the
186 * BLEND_NO_SEPARATE bit is set.
188 * Especially problematic candidates are the ONE_MINUS_* flags,
189 * but I can't see a real pattern.
192 if (new_ablend
== new_cblend
) {
193 new_cblend
|= R300_BLEND_NO_SEPARATE
;
198 if ((new_ablend
!= r300
->hw
.bld
.cmd
[R300_BLD_ABLEND
]) ||
199 (new_cblend
!= r300
->hw
.bld
.cmd
[R300_BLD_CBLEND
])) {
200 R300_STATECHANGE(r300
, bld
);
201 r300
->hw
.bld
.cmd
[R300_BLD_ABLEND
] = new_ablend
;
202 r300
->hw
.bld
.cmd
[R300_BLD_CBLEND
] = new_cblend
;
206 static void r300SetBlendState(GLcontext
* ctx
)
208 r300ContextPtr r300
= R300_CONTEXT(ctx
);
209 int func
= (R300_BLEND_GL_ONE
<< R300_SRC_BLEND_SHIFT
) |
210 (R300_BLEND_GL_ZERO
<< R300_DST_BLEND_SHIFT
);
211 int eqn
= R300_COMB_FCN_ADD_CLAMP
;
212 int funcA
= (R300_BLEND_GL_ONE
<< R300_SRC_BLEND_SHIFT
) |
213 (R300_BLEND_GL_ZERO
<< R300_DST_BLEND_SHIFT
);
214 int eqnA
= R300_COMB_FCN_ADD_CLAMP
;
216 if (RGBA_LOGICOP_ENABLED(ctx
) || !ctx
->Color
.BlendEnabled
) {
217 r300SetBlendCntl(r300
, func
, eqn
, 0, func
, eqn
);
222 (blend_factor(ctx
->Color
.BlendSrcRGB
, GL_TRUE
) <<
223 R300_SRC_BLEND_SHIFT
) | (blend_factor(ctx
->Color
.BlendDstRGB
,
225 R300_DST_BLEND_SHIFT
);
227 switch (ctx
->Color
.BlendEquationRGB
) {
229 eqn
= R300_COMB_FCN_ADD_CLAMP
;
232 case GL_FUNC_SUBTRACT
:
233 eqn
= R300_COMB_FCN_SUB_CLAMP
;
236 case GL_FUNC_REVERSE_SUBTRACT
:
237 eqn
= R300_COMB_FCN_RSUB_CLAMP
;
241 eqn
= R300_COMB_FCN_MIN
;
242 func
= (R300_BLEND_GL_ONE
<< R300_SRC_BLEND_SHIFT
) |
243 (R300_BLEND_GL_ONE
<< R300_DST_BLEND_SHIFT
);
247 eqn
= R300_COMB_FCN_MAX
;
248 func
= (R300_BLEND_GL_ONE
<< R300_SRC_BLEND_SHIFT
) |
249 (R300_BLEND_GL_ONE
<< R300_DST_BLEND_SHIFT
);
254 "[%s:%u] Invalid RGB blend equation (0x%04x).\n",
255 __FUNCTION__
, __LINE__
, ctx
->Color
.BlendEquationRGB
);
260 (blend_factor(ctx
->Color
.BlendSrcA
, GL_TRUE
) <<
261 R300_SRC_BLEND_SHIFT
) | (blend_factor(ctx
->Color
.BlendDstA
,
263 R300_DST_BLEND_SHIFT
);
265 switch (ctx
->Color
.BlendEquationA
) {
267 eqnA
= R300_COMB_FCN_ADD_CLAMP
;
270 case GL_FUNC_SUBTRACT
:
271 eqnA
= R300_COMB_FCN_SUB_CLAMP
;
274 case GL_FUNC_REVERSE_SUBTRACT
:
275 eqnA
= R300_COMB_FCN_RSUB_CLAMP
;
279 eqnA
= R300_COMB_FCN_MIN
;
280 funcA
= (R300_BLEND_GL_ONE
<< R300_SRC_BLEND_SHIFT
) |
281 (R300_BLEND_GL_ONE
<< R300_DST_BLEND_SHIFT
);
285 eqnA
= R300_COMB_FCN_MAX
;
286 funcA
= (R300_BLEND_GL_ONE
<< R300_SRC_BLEND_SHIFT
) |
287 (R300_BLEND_GL_ONE
<< R300_DST_BLEND_SHIFT
);
292 "[%s:%u] Invalid A blend equation (0x%04x).\n",
293 __FUNCTION__
, __LINE__
, ctx
->Color
.BlendEquationA
);
297 r300SetBlendCntl(r300
,
299 R300_BLEND_UNKNOWN
| R300_BLEND_ENABLE
, funcA
, eqnA
);
302 static void r300BlendEquationSeparate(GLcontext
* ctx
,
303 GLenum modeRGB
, GLenum modeA
)
305 r300SetBlendState(ctx
);
308 static void r300BlendFuncSeparate(GLcontext
* ctx
,
309 GLenum sfactorRGB
, GLenum dfactorRGB
,
310 GLenum sfactorA
, GLenum dfactorA
)
312 r300SetBlendState(ctx
);
316 * Update our tracked culling state based on Mesa's state.
318 static void r300UpdateCulling(GLcontext
* ctx
)
320 r300ContextPtr r300
= R300_CONTEXT(ctx
);
323 if (ctx
->Polygon
.CullFlag
) {
324 switch (ctx
->Polygon
.CullFaceMode
) {
326 val
= R300_CULL_FRONT
;
329 val
= R300_CULL_BACK
;
331 case GL_FRONT_AND_BACK
:
332 val
= R300_CULL_FRONT
| R300_CULL_BACK
;
339 switch (ctx
->Polygon
.FrontFace
) {
341 val
|= R300_FRONT_FACE_CW
;
344 val
|= R300_FRONT_FACE_CCW
;
350 R300_STATECHANGE(r300
, cul
);
351 r300
->hw
.cul
.cmd
[R300_CUL_CULL
] = val
;
354 static void r300SetEarlyZState(GLcontext
* ctx
)
356 /* updates register R300_RB3D_EARLY_Z (0x4F14)
357 if depth test is not enabled it should be R300_EARLY_Z_DISABLE
358 if depth is enabled and alpha not it should be R300_EARLY_Z_ENABLE
359 if depth and alpha is enabled it should be R300_EARLY_Z_DISABLE
361 r300ContextPtr r300
= R300_CONTEXT(ctx
);
363 R300_STATECHANGE(r300
, zstencil_format
);
364 switch (ctx
->Visual
.depthBits
) {
366 r300
->hw
.zstencil_format
.cmd
[1] = R300_DEPTH_FORMAT_16BIT_INT_Z
;
369 r300
->hw
.zstencil_format
.cmd
[1] = R300_DEPTH_FORMAT_24BIT_INT_Z
;
372 fprintf(stderr
, "Error: Unsupported depth %d... exiting\n", ctx
->Visual
.depthBits
);
376 // r300->hw.zstencil_format.cmd[1] |= R300_DEPTH_FORMAT_UNK32;
378 if (ctx
->Color
.AlphaEnabled
&& ctx
->Color
.AlphaFunc
!= GL_ALWAYS
)
379 /* disable early Z */
380 r300
->hw
.zstencil_format
.cmd
[2] = R300_EARLY_Z_DISABLE
;
382 if (ctx
->Depth
.Test
&& ctx
->Depth
.Func
!= GL_NEVER
)
384 r300
->hw
.zstencil_format
.cmd
[2] = R300_EARLY_Z_ENABLE
;
386 /* disable early Z */
387 r300
->hw
.zstencil_format
.cmd
[2] = R300_EARLY_Z_DISABLE
;
390 r300
->hw
.zstencil_format
.cmd
[3] = 0x00000003;
391 r300
->hw
.zstencil_format
.cmd
[4] = 0x00000000;
394 static void r300SetAlphaState(GLcontext
* ctx
)
396 r300ContextPtr r300
= R300_CONTEXT(ctx
);
398 uint32_t pp_misc
= 0x0;
399 GLboolean really_enabled
= ctx
->Color
.AlphaEnabled
;
401 CLAMPED_FLOAT_TO_UBYTE(refByte
, ctx
->Color
.AlphaRef
);
403 switch (ctx
->Color
.AlphaFunc
) {
405 pp_misc
|= R300_ALPHA_TEST_FAIL
;
408 pp_misc
|= R300_ALPHA_TEST_LESS
;
411 pp_misc
|= R300_ALPHA_TEST_EQUAL
;
414 pp_misc
|= R300_ALPHA_TEST_LEQUAL
;
417 pp_misc
|= R300_ALPHA_TEST_GREATER
;
420 pp_misc
|= R300_ALPHA_TEST_NEQUAL
;
423 pp_misc
|= R300_ALPHA_TEST_GEQUAL
;
426 /*pp_misc |= R300_ALPHA_TEST_PASS; */
427 really_enabled
= GL_FALSE
;
431 if (really_enabled
) {
432 pp_misc
|= R300_ALPHA_TEST_ENABLE
;
433 pp_misc
|= (refByte
& R300_REF_ALPHA_MASK
);
438 R300_STATECHANGE(r300
, at
);
439 r300
->hw
.at
.cmd
[R300_AT_ALPHA_TEST
] = pp_misc
;
440 r300
->hw
.at
.cmd
[R300_AT_UNKNOWN
] = 0;
442 r300SetEarlyZState(ctx
);
445 static void r300AlphaFunc(GLcontext
* ctx
, GLenum func
, GLfloat ref
)
449 r300SetAlphaState(ctx
);
452 static int translate_func(int func
)
456 return R300_ZS_NEVER
;
460 return R300_ZS_EQUAL
;
462 return R300_ZS_LEQUAL
;
464 return R300_ZS_GREATER
;
466 return R300_ZS_NOTEQUAL
;
468 return R300_ZS_GEQUAL
;
470 return R300_ZS_ALWAYS
;
475 static void r300SetDepthState(GLcontext
* ctx
)
477 r300ContextPtr r300
= R300_CONTEXT(ctx
);
479 R300_STATECHANGE(r300
, zs
);
480 r300
->hw
.zs
.cmd
[R300_ZS_CNTL_0
] &= R300_RB3D_STENCIL_ENABLE
;
481 r300
->hw
.zs
.cmd
[R300_ZS_CNTL_1
] &=
482 ~(R300_ZS_MASK
<< R300_RB3D_ZS1_DEPTH_FUNC_SHIFT
);
484 if (ctx
->Depth
.Test
&& ctx
->Depth
.Func
!= GL_NEVER
) {
486 r300
->hw
.zs
.cmd
[R300_ZS_CNTL_0
] |=
487 R300_RB3D_Z_TEST_AND_WRITE
;
489 r300
->hw
.zs
.cmd
[R300_ZS_CNTL_0
] |= R300_RB3D_Z_TEST
;
491 r300
->hw
.zs
.cmd
[R300_ZS_CNTL_1
] |=
492 translate_func(ctx
->Depth
.
493 Func
) << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT
;
495 r300
->hw
.zs
.cmd
[R300_ZS_CNTL_0
] |= R300_RB3D_Z_DISABLED_1
;
496 r300
->hw
.zs
.cmd
[R300_ZS_CNTL_1
] |=
497 translate_func(GL_NEVER
) << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT
;
500 r300SetEarlyZState(ctx
);
503 static void r300UpdatePolygonMode(GLcontext
* ctx
)
505 r300ContextPtr r300
= R300_CONTEXT(ctx
);
506 uint32_t hw_mode
= 0;
508 if (ctx
->Polygon
.FrontMode
!= GL_FILL
||
509 ctx
->Polygon
.BackMode
!= GL_FILL
) {
512 if (ctx
->Polygon
.FrontFace
== GL_CCW
) {
513 f
= ctx
->Polygon
.FrontMode
;
514 b
= ctx
->Polygon
.BackMode
;
516 f
= ctx
->Polygon
.BackMode
;
517 b
= ctx
->Polygon
.FrontMode
;
520 hw_mode
|= R300_PM_ENABLED
;
524 hw_mode
|= R300_PM_FRONT_LINE
;
526 case GL_POINT
: /* noop */
527 hw_mode
|= R300_PM_FRONT_POINT
;
530 hw_mode
|= R300_PM_FRONT_FILL
;
536 hw_mode
|= R300_PM_BACK_LINE
;
538 case GL_POINT
: /* noop */
539 hw_mode
|= R300_PM_BACK_POINT
;
542 hw_mode
|= R300_PM_BACK_FILL
;
547 if (r300
->hw
.polygon_mode
.cmd
[1] != hw_mode
) {
548 R300_STATECHANGE(r300
, polygon_mode
);
549 r300
->hw
.polygon_mode
.cmd
[1] = hw_mode
;
552 r300
->hw
.polygon_mode
.cmd
[2] = 0x00000001;
553 r300
->hw
.polygon_mode
.cmd
[3] = 0x00000000;
557 * Change the culling mode.
559 * \note Mesa already filters redundant calls to this function.
561 static void r300CullFace(GLcontext
* ctx
, GLenum mode
)
565 r300UpdateCulling(ctx
);
569 * Change the polygon orientation.
571 * \note Mesa already filters redundant calls to this function.
573 static void r300FrontFace(GLcontext
* ctx
, GLenum mode
)
577 r300UpdateCulling(ctx
);
578 r300UpdatePolygonMode(ctx
);
582 * Change the depth testing function.
584 * \note Mesa already filters redundant calls to this function.
586 static void r300DepthFunc(GLcontext
* ctx
, GLenum func
)
589 r300SetDepthState(ctx
);
593 * Enable/Disable depth writing.
595 * \note Mesa already filters redundant calls to this function.
597 static void r300DepthMask(GLcontext
* ctx
, GLboolean mask
)
600 r300SetDepthState(ctx
);
604 * Handle glColorMask()
606 static void r300ColorMask(GLcontext
* ctx
,
607 GLboolean r
, GLboolean g
, GLboolean b
, GLboolean a
)
609 r300ContextPtr r300
= R300_CONTEXT(ctx
);
610 int mask
= (r
? R300_COLORMASK0_R
: 0) |
611 (g
? R300_COLORMASK0_G
: 0) |
612 (b
? R300_COLORMASK0_B
: 0) | (a
? R300_COLORMASK0_A
: 0);
614 if (mask
!= r300
->hw
.cmk
.cmd
[R300_CMK_COLORMASK
]) {
615 R300_STATECHANGE(r300
, cmk
);
616 r300
->hw
.cmk
.cmd
[R300_CMK_COLORMASK
] = mask
;
620 /* =============================================================
623 static void r300Fogfv(GLcontext
* ctx
, GLenum pname
, const GLfloat
* param
)
625 r300ContextPtr r300
= R300_CONTEXT(ctx
);
629 } fogScale
, fogStart
;
633 fogScale
.i
= r300
->hw
.fogp
.cmd
[R300_FOGP_SCALE
];
634 fogStart
.i
= r300
->hw
.fogp
.cmd
[R300_FOGP_START
];
638 if (!ctx
->Fog
.Enabled
)
640 switch (ctx
->Fog
.Mode
) {
642 R300_STATECHANGE(r300
, fogs
);
643 r300
->hw
.fogs
.cmd
[R300_FOGS_STATE
] =
645 cmd
[R300_FOGS_STATE
] & ~R300_FOG_MODE_MASK
) |
646 R300_FOG_MODE_LINEAR
;
648 if (ctx
->Fog
.Start
== ctx
->Fog
.End
) {
653 1.0 / (ctx
->Fog
.End
- ctx
->Fog
.Start
);
655 -ctx
->Fog
.Start
/ (ctx
->Fog
.End
-
660 R300_STATECHANGE(r300
, fogs
);
661 r300
->hw
.fogs
.cmd
[R300_FOGS_STATE
] =
663 cmd
[R300_FOGS_STATE
] & ~R300_FOG_MODE_MASK
) |
665 fogScale
.f
= 0.0933 * ctx
->Fog
.Density
;
669 R300_STATECHANGE(r300
, fogs
);
670 r300
->hw
.fogs
.cmd
[R300_FOGS_STATE
] =
672 cmd
[R300_FOGS_STATE
] & ~R300_FOG_MODE_MASK
) |
674 fogScale
.f
= 0.3 * ctx
->Fog
.Density
;
681 switch (ctx
->Fog
.Mode
) {
683 fogScale
.f
= 0.0933 * ctx
->Fog
.Density
;
687 fogScale
.f
= 0.3 * ctx
->Fog
.Density
;
695 if (ctx
->Fog
.Mode
== GL_LINEAR
) {
696 if (ctx
->Fog
.Start
== ctx
->Fog
.End
) {
701 1.0 / (ctx
->Fog
.End
- ctx
->Fog
.Start
);
703 -ctx
->Fog
.Start
/ (ctx
->Fog
.End
-
709 R300_STATECHANGE(r300
, fogc
);
710 r300
->hw
.fogc
.cmd
[R300_FOGC_R
] =
711 (GLuint
) (ctx
->Fog
.Color
[0] * 1023.0F
) & 0x3FF;
712 r300
->hw
.fogc
.cmd
[R300_FOGC_G
] =
713 (GLuint
) (ctx
->Fog
.Color
[1] * 1023.0F
) & 0x3FF;
714 r300
->hw
.fogc
.cmd
[R300_FOGC_B
] =
715 (GLuint
) (ctx
->Fog
.Color
[2] * 1023.0F
) & 0x3FF;
717 case GL_FOG_COORD_SRC
:
723 if (fogScale
.i
!= r300
->hw
.fogp
.cmd
[R300_FOGP_SCALE
] ||
724 fogStart
.i
!= r300
->hw
.fogp
.cmd
[R300_FOGP_START
]) {
725 R300_STATECHANGE(r300
, fogp
);
726 r300
->hw
.fogp
.cmd
[R300_FOGP_SCALE
] = fogScale
.i
;
727 r300
->hw
.fogp
.cmd
[R300_FOGP_START
] = fogStart
.i
;
731 /* =============================================================
734 static void r300PointSize(GLcontext
* ctx
, GLfloat size
)
736 r300ContextPtr r300
= R300_CONTEXT(ctx
);
737 /* same size limits for AA, non-AA points */
738 size
= CLAMP(size
, ctx
->Const
.MinPointSize
, ctx
->Const
.MaxPointSize
);
740 R300_STATECHANGE(r300
, ps
);
741 r300
->hw
.ps
.cmd
[R300_PS_POINTSIZE
] =
742 ((int)(size
* 6) << R300_POINTSIZE_X_SHIFT
) |
743 ((int)(size
* 6) << R300_POINTSIZE_Y_SHIFT
);
746 /* =============================================================
749 static void r300LineWidth(GLcontext
* ctx
, GLfloat widthf
)
751 r300ContextPtr r300
= R300_CONTEXT(ctx
);
753 widthf
= CLAMP(widthf
,
754 ctx
->Const
.MinPointSize
,
755 ctx
->Const
.MaxPointSize
);
756 R300_STATECHANGE(r300
, lcntl
);
757 r300
->hw
.lcntl
.cmd
[1] =
758 R300_LINE_CNT_HO
| R300_LINE_CNT_VE
| (int)(widthf
* 6.0);
761 static void r300PolygonMode(GLcontext
* ctx
, GLenum face
, GLenum mode
)
766 r300UpdatePolygonMode(ctx
);
769 /* =============================================================
773 static int translate_stencil_op(int op
)
781 return R300_ZS_REPLACE
;
786 case GL_INCR_WRAP_EXT
:
787 return R300_ZS_INCR_WRAP
;
788 case GL_DECR_WRAP_EXT
:
789 return R300_ZS_DECR_WRAP
;
791 return R300_ZS_INVERT
;
793 WARN_ONCE("Do not know how to translate stencil op");
799 static void r300ShadeModel(GLcontext
* ctx
, GLenum mode
)
801 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
803 R300_STATECHANGE(rmesa
, shade
);
804 rmesa
->hw
.shade
.cmd
[1] = 0x00000002;
807 rmesa
->hw
.shade
.cmd
[2] = R300_RE_SHADE_MODEL_FLAT
;
810 rmesa
->hw
.shade
.cmd
[2] = R300_RE_SHADE_MODEL_SMOOTH
;
815 rmesa
->hw
.shade
.cmd
[3] = 0x00000000;
816 rmesa
->hw
.shade
.cmd
[4] = 0x00000000;
819 static void r300StencilFuncSeparate(GLcontext
* ctx
, GLenum face
,
820 GLenum func
, GLint ref
, GLuint mask
)
822 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
825 Ref
[0] & 0xff) << R300_RB3D_ZS2_STENCIL_REF_SHIFT
) | ((ctx
->
831 R300_RB3D_ZS2_STENCIL_MASK_SHIFT
));
835 R300_STATECHANGE(rmesa
, zs
);
837 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_1
] &= ~((R300_ZS_MASK
<<
838 R300_RB3D_ZS1_FRONT_FUNC_SHIFT
)
840 R300_RB3D_ZS1_BACK_FUNC_SHIFT
));
842 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_2
] &=
843 ~((R300_RB3D_ZS2_STENCIL_MASK
<<
844 R300_RB3D_ZS2_STENCIL_REF_SHIFT
) |
845 (R300_RB3D_ZS2_STENCIL_MASK
<< R300_RB3D_ZS2_STENCIL_MASK_SHIFT
));
847 flag
= translate_func(ctx
->Stencil
.Function
[0]);
848 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_1
] |=
849 (flag
<< R300_RB3D_ZS1_FRONT_FUNC_SHIFT
);
851 if (ctx
->Stencil
._TestTwoSide
)
852 flag
= translate_func(ctx
->Stencil
.Function
[1]);
854 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_1
] |=
855 (flag
<< R300_RB3D_ZS1_BACK_FUNC_SHIFT
);
856 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_2
] |= refmask
;
859 static void r300StencilMaskSeparate(GLcontext
* ctx
, GLenum face
, GLuint mask
)
861 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
863 R300_STATECHANGE(rmesa
, zs
);
864 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_2
] &=
865 ~(R300_RB3D_ZS2_STENCIL_MASK
<<
866 R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT
);
867 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_2
] |=
869 WriteMask
[0] & 0xff) << R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT
;
872 static void r300StencilOpSeparate(GLcontext
* ctx
, GLenum face
,
873 GLenum fail
, GLenum zfail
, GLenum zpass
)
875 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
877 R300_STATECHANGE(rmesa
, zs
);
878 /* It is easier to mask what's left.. */
879 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_1
] &=
880 (R300_ZS_MASK
<< R300_RB3D_ZS1_DEPTH_FUNC_SHIFT
) |
881 (R300_ZS_MASK
<< R300_RB3D_ZS1_FRONT_FUNC_SHIFT
) |
882 (R300_ZS_MASK
<< R300_RB3D_ZS1_BACK_FUNC_SHIFT
);
884 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_1
] |=
885 (translate_stencil_op(ctx
->Stencil
.FailFunc
[0]) <<
886 R300_RB3D_ZS1_FRONT_FAIL_OP_SHIFT
)
887 | (translate_stencil_op(ctx
->Stencil
.ZFailFunc
[0]) <<
888 R300_RB3D_ZS1_FRONT_ZFAIL_OP_SHIFT
)
889 | (translate_stencil_op(ctx
->Stencil
.ZPassFunc
[0]) <<
890 R300_RB3D_ZS1_FRONT_ZPASS_OP_SHIFT
);
892 if (ctx
->Stencil
._TestTwoSide
) {
893 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_1
] |=
894 (translate_stencil_op(ctx
->Stencil
.FailFunc
[1]) <<
895 R300_RB3D_ZS1_BACK_FAIL_OP_SHIFT
)
896 | (translate_stencil_op(ctx
->Stencil
.ZFailFunc
[1]) <<
897 R300_RB3D_ZS1_BACK_ZFAIL_OP_SHIFT
)
898 | (translate_stencil_op(ctx
->Stencil
.ZPassFunc
[1]) <<
899 R300_RB3D_ZS1_BACK_ZPASS_OP_SHIFT
);
901 rmesa
->hw
.zs
.cmd
[R300_ZS_CNTL_1
] |=
902 (translate_stencil_op(ctx
->Stencil
.FailFunc
[0]) <<
903 R300_RB3D_ZS1_BACK_FAIL_OP_SHIFT
)
904 | (translate_stencil_op(ctx
->Stencil
.ZFailFunc
[0]) <<
905 R300_RB3D_ZS1_BACK_ZFAIL_OP_SHIFT
)
906 | (translate_stencil_op(ctx
->Stencil
.ZPassFunc
[0]) <<
907 R300_RB3D_ZS1_BACK_ZPASS_OP_SHIFT
);
911 static void r300ClearStencil(GLcontext
* ctx
, GLint s
)
913 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
915 rmesa
->state
.stencil
.clear
=
916 ((GLuint
) (ctx
->Stencil
.Clear
& 0xff) |
917 (R300_RB3D_ZS2_STENCIL_MASK
<<
918 R300_RB3D_ZS2_STENCIL_MASK_SHIFT
) | ((ctx
->Stencil
.
919 WriteMask
[0] & 0xff) <<
920 R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT
));
923 /* =============================================================
924 * Window position and viewport transformation
928 * To correctly position primitives:
930 #define SUBPIXEL_X 0.125
931 #define SUBPIXEL_Y 0.125
933 static void r300UpdateWindow(GLcontext
* ctx
)
935 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
936 __DRIdrawablePrivate
*dPriv
= rmesa
->radeon
.dri
.drawable
;
937 GLfloat xoffset
= dPriv
? (GLfloat
) dPriv
->x
: 0;
938 GLfloat yoffset
= dPriv
? (GLfloat
) dPriv
->y
+ dPriv
->h
: 0;
939 const GLfloat
*v
= ctx
->Viewport
._WindowMap
.m
;
941 GLfloat sx
= v
[MAT_SX
];
942 GLfloat tx
= v
[MAT_TX
] + xoffset
+ SUBPIXEL_X
;
943 GLfloat sy
= -v
[MAT_SY
];
944 GLfloat ty
= (-v
[MAT_TY
]) + yoffset
+ SUBPIXEL_Y
;
945 GLfloat sz
= v
[MAT_SZ
] * rmesa
->state
.depth
.scale
;
946 GLfloat tz
= v
[MAT_TZ
] * rmesa
->state
.depth
.scale
;
948 R300_FIREVERTICES(rmesa
);
949 R300_STATECHANGE(rmesa
, vpt
);
951 rmesa
->hw
.vpt
.cmd
[R300_VPT_XSCALE
] = r300PackFloat32(sx
);
952 rmesa
->hw
.vpt
.cmd
[R300_VPT_XOFFSET
] = r300PackFloat32(tx
);
953 rmesa
->hw
.vpt
.cmd
[R300_VPT_YSCALE
] = r300PackFloat32(sy
);
954 rmesa
->hw
.vpt
.cmd
[R300_VPT_YOFFSET
] = r300PackFloat32(ty
);
955 rmesa
->hw
.vpt
.cmd
[R300_VPT_ZSCALE
] = r300PackFloat32(sz
);
956 rmesa
->hw
.vpt
.cmd
[R300_VPT_ZOFFSET
] = r300PackFloat32(tz
);
959 static void r300Viewport(GLcontext
* ctx
, GLint x
, GLint y
,
960 GLsizei width
, GLsizei height
)
962 /* Don't pipeline viewport changes, conflict with window offset
963 * setting below. Could apply deltas to rescue pipelined viewport
964 * values, or keep the originals hanging around.
966 r300UpdateWindow(ctx
);
969 static void r300DepthRange(GLcontext
* ctx
, GLclampd nearval
, GLclampd farval
)
971 r300UpdateWindow(ctx
);
974 void r300UpdateViewportOffset(GLcontext
* ctx
)
976 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
977 __DRIdrawablePrivate
*dPriv
= ((radeonContextPtr
) rmesa
)->dri
.drawable
;
978 GLfloat xoffset
= (GLfloat
) dPriv
->x
;
979 GLfloat yoffset
= (GLfloat
) dPriv
->y
+ dPriv
->h
;
980 const GLfloat
*v
= ctx
->Viewport
._WindowMap
.m
;
982 GLfloat tx
= v
[MAT_TX
] + xoffset
+ SUBPIXEL_X
;
983 GLfloat ty
= (-v
[MAT_TY
]) + yoffset
+ SUBPIXEL_Y
;
985 if (rmesa
->hw
.vpt
.cmd
[R300_VPT_XOFFSET
] != r300PackFloat32(tx
) ||
986 rmesa
->hw
.vpt
.cmd
[R300_VPT_YOFFSET
] != r300PackFloat32(ty
)) {
987 /* Note: this should also modify whatever data the context reset
990 R300_STATECHANGE(rmesa
, vpt
);
991 rmesa
->hw
.vpt
.cmd
[R300_VPT_XOFFSET
] = r300PackFloat32(tx
);
992 rmesa
->hw
.vpt
.cmd
[R300_VPT_YOFFSET
] = r300PackFloat32(ty
);
996 radeonUpdateScissor(ctx
);
1000 * Tell the card where to render (offset, pitch).
1001 * Effected by glDrawBuffer, etc
1003 void r300UpdateDrawBuffer(GLcontext
* ctx
)
1005 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
1006 r300ContextPtr r300
= rmesa
;
1007 struct gl_framebuffer
*fb
= ctx
->DrawBuffer
;
1008 driRenderbuffer
*drb
;
1010 if (fb
->_ColorDrawBufferMask
[0] == BUFFER_BIT_FRONT_LEFT
) {
1013 (driRenderbuffer
*) fb
->Attachment
[BUFFER_FRONT_LEFT
].
1015 } else if (fb
->_ColorDrawBufferMask
[0] == BUFFER_BIT_BACK_LEFT
) {
1018 (driRenderbuffer
*) fb
->Attachment
[BUFFER_BACK_LEFT
].
1021 /* drawing to multiple buffers, or none */
1026 assert(drb
->flippedPitch
);
1028 R300_STATECHANGE(rmesa
, cb
);
1030 r300
->hw
.cb
.cmd
[R300_CB_OFFSET
] = drb
->flippedOffset
+ //r300->radeon.state.color.drawOffset +
1031 r300
->radeon
.radeonScreen
->fbLocation
;
1032 r300
->hw
.cb
.cmd
[R300_CB_PITCH
] = drb
->flippedPitch
; //r300->radeon.state.color.drawPitch;
1034 if (r300
->radeon
.radeonScreen
->cpp
== 4)
1035 r300
->hw
.cb
.cmd
[R300_CB_PITCH
] |= R300_COLOR_FORMAT_ARGB8888
;
1037 r300
->hw
.cb
.cmd
[R300_CB_PITCH
] |= R300_COLOR_FORMAT_RGB565
;
1039 if (r300
->radeon
.sarea
->tiling_enabled
)
1040 r300
->hw
.cb
.cmd
[R300_CB_PITCH
] |= R300_COLOR_TILE_ENABLE
;
1042 R200_STATECHANGE(rmesa
, ctx
);
1044 /* Note: we used the (possibly) page-flipped values */
1045 rmesa
->hw
.ctx
.cmd
[CTX_RB3D_COLOROFFSET
]
1046 = ((drb
->flippedOffset
+ rmesa
->r200Screen
->fbLocation
)
1047 & R200_COLOROFFSET_MASK
);
1048 rmesa
->hw
.ctx
.cmd
[CTX_RB3D_COLORPITCH
] = drb
->flippedPitch
;
1050 if (rmesa
->sarea
->tiling_enabled
) {
1051 rmesa
->hw
.ctx
.cmd
[CTX_RB3D_COLORPITCH
] |=
1052 R200_COLOR_TILE_ENABLE
;
1058 r300FetchStateParameter(GLcontext
* ctx
,
1059 const gl_state_index state
[STATE_LENGTH
],
1062 r300ContextPtr r300
= R300_CONTEXT(ctx
);
1065 case STATE_INTERNAL
:
1067 case STATE_R300_WINDOW_DIMENSION
:
1068 value
[0] = r300
->radeon
.dri
.drawable
->w
* 0.5f
; /* width*0.5 */
1069 value
[1] = r300
->radeon
.dri
.drawable
->h
* 0.5f
; /* height*0.5 */
1070 value
[2] = 0.5F
; /* for moving range [-1 1] -> [0 1] */
1071 value
[3] = 1.0F
; /* not used */
1074 case STATE_R300_TEXRECT_FACTOR
:{
1075 struct gl_texture_object
*t
=
1076 ctx
->Texture
.Unit
[state
[2]].CurrentRect
;
1078 if (t
&& t
->Image
[0][t
->BaseLevel
]) {
1079 struct gl_texture_image
*image
=
1080 t
->Image
[0][t
->BaseLevel
];
1081 value
[0] = 1.0 / image
->Width2
;
1082 value
[1] = 1.0 / image
->Height2
;
1103 * Update R300's own internal state parameters.
1104 * For now just STATE_R300_WINDOW_DIMENSION
1106 void r300UpdateStateParameters(GLcontext
* ctx
, GLuint new_state
)
1108 struct r300_fragment_program
*fp
;
1109 struct gl_program_parameter_list
*paramList
;
1112 if (!(new_state
& (_NEW_BUFFERS
| _NEW_PROGRAM
)))
1115 fp
= (struct r300_fragment_program
*)ctx
->FragmentProgram
._Current
;
1119 paramList
= fp
->mesa_program
.Base
.Parameters
;
1124 for (i
= 0; i
< paramList
->NumParameters
; i
++) {
1125 if (paramList
->Parameters
[i
].Type
== PROGRAM_STATE_VAR
) {
1126 r300FetchStateParameter(ctx
,
1127 paramList
->Parameters
[i
].
1129 paramList
->ParameterValues
[i
]);
1134 /* =============================================================
1137 static void r300PolygonOffset(GLcontext
* ctx
, GLfloat factor
, GLfloat units
)
1139 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
1140 GLfloat constant
= units
;
1142 switch (ctx
->Visual
.depthBits
) {
1153 /* fprintf(stderr, "%s f:%f u:%f\n", __FUNCTION__, factor, constant); */
1155 R300_STATECHANGE(rmesa
, zbs
);
1156 rmesa
->hw
.zbs
.cmd
[R300_ZBS_T_FACTOR
] = r300PackFloat32(factor
);
1157 rmesa
->hw
.zbs
.cmd
[R300_ZBS_T_CONSTANT
] = r300PackFloat32(constant
);
1158 rmesa
->hw
.zbs
.cmd
[R300_ZBS_W_FACTOR
] = r300PackFloat32(factor
);
1159 rmesa
->hw
.zbs
.cmd
[R300_ZBS_W_CONSTANT
] = r300PackFloat32(constant
);
1162 /* Routing and texture-related */
1164 /* r300 doesnt handle GL_CLAMP and GL_MIRROR_CLAMP_EXT correctly when filter is NEAREST.
1165 * Since texwrap produces same results for GL_CLAMP and GL_CLAMP_TO_EDGE we use them instead.
1166 * We need to recalculate wrap modes whenever filter mode is changed because someone might do:
1167 * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1168 * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
1169 * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1170 * Since r300 completely ignores R300_TX_CLAMP when either min or mag is nearest it cant handle
1171 * combinations where only one of them is nearest.
1173 static unsigned long gen_fixed_filter(unsigned long f
)
1175 unsigned long mag
, min
, needs_fixing
= 0;
1178 /* We ignore MIRROR bit so we dont have to do everything twice */
1179 if ((f
& ((7 - 1) << R300_TX_WRAP_S_SHIFT
)) ==
1180 (R300_TX_CLAMP
<< R300_TX_WRAP_S_SHIFT
)) {
1183 if ((f
& ((7 - 1) << R300_TX_WRAP_T_SHIFT
)) ==
1184 (R300_TX_CLAMP
<< R300_TX_WRAP_T_SHIFT
)) {
1187 if ((f
& ((7 - 1) << R300_TX_WRAP_Q_SHIFT
)) ==
1188 (R300_TX_CLAMP
<< R300_TX_WRAP_Q_SHIFT
)) {
1195 mag
= f
& R300_TX_MAG_FILTER_MASK
;
1196 min
= f
& R300_TX_MIN_FILTER_MASK
;
1198 /* TODO: Check for anisto filters too */
1199 if ((mag
!= R300_TX_MAG_FILTER_NEAREST
)
1200 && (min
!= R300_TX_MIN_FILTER_NEAREST
))
1203 /* r300 cant handle these modes hence we force nearest to linear */
1204 if ((mag
== R300_TX_MAG_FILTER_NEAREST
)
1205 && (min
!= R300_TX_MIN_FILTER_NEAREST
)) {
1206 f
&= ~R300_TX_MAG_FILTER_NEAREST
;
1207 f
|= R300_TX_MAG_FILTER_LINEAR
;
1211 if ((min
== R300_TX_MIN_FILTER_NEAREST
)
1212 && (mag
!= R300_TX_MAG_FILTER_NEAREST
)) {
1213 f
&= ~R300_TX_MIN_FILTER_NEAREST
;
1214 f
|= R300_TX_MIN_FILTER_LINEAR
;
1218 /* Both are nearest */
1219 if (needs_fixing
& 1) {
1220 f
&= ~((7 - 1) << R300_TX_WRAP_S_SHIFT
);
1221 f
|= R300_TX_CLAMP_TO_EDGE
<< R300_TX_WRAP_S_SHIFT
;
1223 if (needs_fixing
& 2) {
1224 f
&= ~((7 - 1) << R300_TX_WRAP_T_SHIFT
);
1225 f
|= R300_TX_CLAMP_TO_EDGE
<< R300_TX_WRAP_T_SHIFT
;
1227 if (needs_fixing
& 4) {
1228 f
&= ~((7 - 1) << R300_TX_WRAP_Q_SHIFT
);
1229 f
|= R300_TX_CLAMP_TO_EDGE
<< R300_TX_WRAP_Q_SHIFT
;
1234 static void r300SetupTextures(GLcontext
* ctx
)
1237 struct r300_tex_obj
*t
;
1238 r300ContextPtr r300
= R300_CONTEXT(ctx
);
1240 int last_hw_tmu
= -1; /* -1 translates into no setup costs for fields */
1241 int tmu_mappings
[R300_MAX_TEXTURE_UNITS
] = { -1, };
1242 struct r300_fragment_program
*fp
= (struct r300_fragment_program
*)
1243 (char *)ctx
->FragmentProgram
._Current
;
1245 R300_STATECHANGE(r300
, txe
);
1246 R300_STATECHANGE(r300
, tex
.filter
);
1247 R300_STATECHANGE(r300
, tex
.filter_1
);
1248 R300_STATECHANGE(r300
, tex
.size
);
1249 R300_STATECHANGE(r300
, tex
.format
);
1250 R300_STATECHANGE(r300
, tex
.pitch
);
1251 R300_STATECHANGE(r300
, tex
.offset
);
1252 R300_STATECHANGE(r300
, tex
.chroma_key
);
1253 R300_STATECHANGE(r300
, tex
.border_color
);
1255 r300
->hw
.txe
.cmd
[R300_TXE_ENABLE
] = 0x0;
1257 mtu
= r300
->radeon
.glCtx
->Const
.MaxTextureUnits
;
1258 if (RADEON_DEBUG
& DEBUG_STATE
)
1259 fprintf(stderr
, "mtu=%d\n", mtu
);
1261 if (mtu
> R300_MAX_TEXTURE_UNITS
) {
1263 "Aiiee ! mtu=%d is greater than R300_MAX_TEXTURE_UNITS=%d\n",
1264 mtu
, R300_MAX_TEXTURE_UNITS
);
1268 /* We cannot let disabled tmu offsets pass DRM */
1269 for (i
= 0; i
< mtu
; i
++) {
1270 if (ctx
->Texture
.Unit
[i
]._ReallyEnabled
) {
1272 #if 0 /* Enables old behaviour */
1275 tmu_mappings
[i
] = hw_tmu
;
1277 t
= r300
->state
.texture
.unit
[i
].texobj
;
1278 /* XXX questionable fix for bug 9170: */
1282 if ((t
->format
& 0xffffff00) == 0xffffff00) {
1284 ("unknown texture format (entry %x) encountered. Help me !\n",
1288 if (RADEON_DEBUG
& DEBUG_STATE
)
1290 "Activating texture unit %d\n", i
);
1292 r300
->hw
.txe
.cmd
[R300_TXE_ENABLE
] |= (1 << hw_tmu
);
1294 r300
->hw
.tex
.filter
.cmd
[R300_TEX_VALUE_0
+
1296 gen_fixed_filter(t
->filter
) | (hw_tmu
<< 28);
1297 /* Currently disabled! */
1298 r300
->hw
.tex
.filter_1
.cmd
[R300_TEX_VALUE_0
+ hw_tmu
] = 0x0; //0x20501f80;
1299 r300
->hw
.tex
.size
.cmd
[R300_TEX_VALUE_0
+ hw_tmu
] =
1301 r300
->hw
.tex
.format
.cmd
[R300_TEX_VALUE_0
+
1302 hw_tmu
] = t
->format
;
1303 r300
->hw
.tex
.pitch
.cmd
[R300_TEX_VALUE_0
+ hw_tmu
] =
1305 r300
->hw
.tex
.offset
.cmd
[R300_TEX_VALUE_0
+
1306 hw_tmu
] = t
->offset
;
1308 if (t
->offset
& R300_TXO_MACRO_TILE
) {
1309 WARN_ONCE("macro tiling enabled!\n");
1312 if (t
->offset
& R300_TXO_MICRO_TILE
) {
1313 WARN_ONCE("micro tiling enabled!\n");
1316 r300
->hw
.tex
.chroma_key
.cmd
[R300_TEX_VALUE_0
+
1318 r300
->hw
.tex
.border_color
.cmd
[R300_TEX_VALUE_0
+
1322 last_hw_tmu
= hw_tmu
;
1328 r300
->hw
.tex
.filter
.cmd
[R300_TEX_CMD_0
] =
1329 cmdpacket0(R300_TX_FILTER_0
, last_hw_tmu
+ 1);
1330 r300
->hw
.tex
.filter_1
.cmd
[R300_TEX_CMD_0
] =
1331 cmdpacket0(R300_TX_FILTER1_0
, last_hw_tmu
+ 1);
1332 r300
->hw
.tex
.size
.cmd
[R300_TEX_CMD_0
] =
1333 cmdpacket0(R300_TX_SIZE_0
, last_hw_tmu
+ 1);
1334 r300
->hw
.tex
.format
.cmd
[R300_TEX_CMD_0
] =
1335 cmdpacket0(R300_TX_FORMAT_0
, last_hw_tmu
+ 1);
1336 r300
->hw
.tex
.pitch
.cmd
[R300_TEX_CMD_0
] =
1337 cmdpacket0(R300_TX_PITCH_0
, last_hw_tmu
+ 1);
1338 r300
->hw
.tex
.offset
.cmd
[R300_TEX_CMD_0
] =
1339 cmdpacket0(R300_TX_OFFSET_0
, last_hw_tmu
+ 1);
1340 r300
->hw
.tex
.chroma_key
.cmd
[R300_TEX_CMD_0
] =
1341 cmdpacket0(R300_TX_CHROMA_KEY_0
, last_hw_tmu
+ 1);
1342 r300
->hw
.tex
.border_color
.cmd
[R300_TEX_CMD_0
] =
1343 cmdpacket0(R300_TX_BORDER_COLOR_0
, last_hw_tmu
+ 1);
1345 if (!fp
) /* should only happenen once, just after context is created */
1348 R300_STATECHANGE(r300
, fpt
);
1350 for (i
= 0; i
< fp
->tex
.length
; i
++) {
1355 unit
= fp
->tex
.inst
[i
] >> R300_FPITX_IMAGE_SHIFT
;
1358 val
= fp
->tex
.inst
[i
];
1359 val
&= ~R300_FPITX_IMAGE_MASK
;
1362 (val
& R300_FPITX_OPCODE_MASK
) >> R300_FPITX_OPCODE_SHIFT
;
1363 if (opcode
== R300_FPITX_OP_KIL
) {
1364 r300
->hw
.fpt
.cmd
[R300_FPT_INSTR_0
+ i
] = val
;
1366 if (tmu_mappings
[unit
] >= 0) {
1368 tmu_mappings
[unit
] <<
1369 R300_FPITX_IMAGE_SHIFT
;
1370 r300
->hw
.fpt
.cmd
[R300_FPT_INSTR_0
+ i
] = val
;
1372 // We get here when the corresponding texture image is incomplete
1373 // (e.g. incomplete mipmaps etc.)
1374 r300
->hw
.fpt
.cmd
[R300_FPT_INSTR_0
+ i
] = val
;
1379 r300
->hw
.fpt
.cmd
[R300_FPT_CMD_0
] =
1380 cmdpacket0(R300_PFS_TEXI_0
, fp
->tex
.length
);
1382 if (RADEON_DEBUG
& DEBUG_STATE
)
1383 fprintf(stderr
, "TX_ENABLE: %08x last_hw_tmu=%d\n",
1384 r300
->hw
.txe
.cmd
[R300_TXE_ENABLE
], last_hw_tmu
);
1387 union r300_outputs_written
{
1388 GLuint vp_outputs
; /* hw_tcl_on */
1389 DECLARE_RENDERINPUTS(index_bitset
); /* !hw_tcl_on */
1392 #define R300_OUTPUTS_WRITTEN_TEST(ow, vp_result, tnl_attrib) \
1393 ((hw_tcl_on) ? (ow).vp_outputs & (1 << (vp_result)) : \
1394 RENDERINPUTS_TEST( (ow.index_bitset), (tnl_attrib) ))
1396 static void r300SetupRSUnit(GLcontext
* ctx
)
1398 r300ContextPtr r300
= R300_CONTEXT(ctx
);
1399 /* I'm still unsure if these are needed */
1400 GLuint interp_magic
[8] = {
1402 R300_RS_INTERP_1_UNKNOWN
,
1403 R300_RS_INTERP_2_UNKNOWN
,
1404 R300_RS_INTERP_3_UNKNOWN
,
1410 union r300_outputs_written OutputsWritten
;
1412 int fp_reg
, high_rr
;
1413 int in_texcoords
, col_interp_nr
;
1417 OutputsWritten
.vp_outputs
= CURRENT_VERTEX_SHADER(ctx
)->key
.OutputsWritten
;
1419 RENDERINPUTS_COPY(OutputsWritten
.index_bitset
, r300
->state
.render_inputs_bitset
);
1421 if (ctx
->FragmentProgram
._Current
)
1422 InputsRead
= ctx
->FragmentProgram
._Current
->Base
.InputsRead
;
1424 fprintf(stderr
, "No ctx->FragmentProgram._Current!!\n");
1425 return; /* This should only ever happen once.. */
1428 R300_STATECHANGE(r300
, ri
);
1429 R300_STATECHANGE(r300
, rc
);
1430 R300_STATECHANGE(r300
, rr
);
1432 fp_reg
= in_texcoords
= col_interp_nr
= high_rr
= 0;
1434 r300
->hw
.rr
.cmd
[R300_RR_ROUTE_1
] = 0;
1436 if (InputsRead
& FRAG_BIT_WPOS
) {
1437 for (i
= 0; i
< ctx
->Const
.MaxTextureUnits
; i
++)
1438 if (!(InputsRead
& (FRAG_BIT_TEX0
<< i
)))
1441 if (i
== ctx
->Const
.MaxTextureUnits
) {
1442 fprintf(stderr
, "\tno free texcoord found...\n");
1446 InputsRead
|= (FRAG_BIT_TEX0
<< i
);
1447 InputsRead
&= ~FRAG_BIT_WPOS
;
1450 for (i
= 0; i
< ctx
->Const
.MaxTextureUnits
; i
++) {
1451 r300
->hw
.ri
.cmd
[R300_RI_INTERP_0
+ i
] = 0 | R300_RS_INTERP_USED
| (in_texcoords
<< R300_RS_INTERP_SRC_SHIFT
)
1454 r300
->hw
.rr
.cmd
[R300_RR_ROUTE_0
+ fp_reg
] = 0;
1455 if (InputsRead
& (FRAG_BIT_TEX0
<< i
)) {
1456 //assert(r300->state.texture.tc_count != 0);
1457 r300
->hw
.rr
.cmd
[R300_RR_ROUTE_0
+ fp_reg
] |= R300_RS_ROUTE_ENABLE
| i
/* source INTERP */
1458 | (fp_reg
<< R300_RS_ROUTE_DEST_SHIFT
);
1461 /* Passing invalid data here can lock the GPU. */
1462 if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten
, VERT_RESULT_TEX0
+ i
, _TNL_ATTRIB_TEX(i
))) {
1463 InputsRead
&= ~(FRAG_BIT_TEX0
<< i
);
1466 WARN_ONCE("fragprog wants coords for tex%d, vp doesn't provide them!\n", i
);
1469 /* Need to count all coords enabled at vof */
1470 if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten
, VERT_RESULT_TEX0
+ i
, _TNL_ATTRIB_TEX(i
))) {
1475 if (InputsRead
& FRAG_BIT_COL0
) {
1476 if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten
, VERT_RESULT_COL0
, _TNL_ATTRIB_COLOR0
)) {
1477 r300
->hw
.rr
.cmd
[R300_RR_ROUTE_0
] |= 0 | R300_RS_ROUTE_0_COLOR
| (fp_reg
++ << R300_RS_ROUTE_0_COLOR_DEST_SHIFT
);
1478 InputsRead
&= ~FRAG_BIT_COL0
;
1481 WARN_ONCE("fragprog wants col0, vp doesn't provide it\n");
1485 if (InputsRead
& FRAG_BIT_COL1
) {
1486 if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten
, VERT_RESULT_COL1
, _TNL_ATTRIB_COLOR1
)) {
1487 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
);
1488 InputsRead
&= ~FRAG_BIT_COL1
;
1493 WARN_ONCE("fragprog wants col1, vp doesn't provide it\n");
1497 /* Need at least one. This might still lock as the values are undefined... */
1498 if (in_texcoords
== 0 && col_interp_nr
== 0) {
1499 r300
->hw
.rr
.cmd
[R300_RR_ROUTE_0
] |= 0 | R300_RS_ROUTE_0_COLOR
| (fp_reg
++ << R300_RS_ROUTE_0_COLOR_DEST_SHIFT
);
1503 r300
->hw
.rc
.cmd
[1] = 0 | (in_texcoords
<< R300_RS_CNTL_TC_CNT_SHIFT
)
1504 | (col_interp_nr
<< R300_RS_CNTL_CI_CNT_SHIFT
)
1505 | R300_RS_CNTL_0_UNKNOWN_18
;
1507 assert(high_rr
>= 0);
1508 r300
->hw
.rr
.cmd
[R300_RR_CMD_0
] = cmdpacket0(R300_RS_ROUTE_0
, high_rr
+ 1);
1509 r300
->hw
.rc
.cmd
[2] = 0xC0 | high_rr
;
1512 WARN_ONCE("Don't know how to satisfy InputsRead=0x%08x\n", InputsRead
);
1515 #define bump_vpu_count(ptr, new_count) do{\
1516 drm_r300_cmd_header_t* _p=((drm_r300_cmd_header_t*)(ptr));\
1517 int _nc=(new_count)/4; \
1518 assert(_nc < 256); \
1519 if(_nc>_p->vpu.count)_p->vpu.count=_nc;\
1522 static inline void r300SetupVertexProgramFragment(r300ContextPtr r300
, int dest
, struct r300_vertex_shader_fragment
*vsf
)
1526 if (vsf
->length
== 0)
1529 if (vsf
->length
& 0x3) {
1530 fprintf(stderr
, "VERTEX_SHADER_FRAGMENT must have length divisible by 4\n");
1534 switch ((dest
>> 8) & 0xf) {
1536 R300_STATECHANGE(r300
, vpi
);
1537 for (i
= 0; i
< vsf
->length
; i
++)
1538 r300
->hw
.vpi
.cmd
[R300_VPI_INSTR_0
+ i
+ 4 * (dest
& 0xff)] = (vsf
->body
.d
[i
]);
1539 bump_vpu_count(r300
->hw
.vpi
.cmd
, vsf
->length
+ 4 * (dest
& 0xff));
1543 R300_STATECHANGE(r300
, vpp
);
1544 for (i
= 0; i
< vsf
->length
; i
++)
1545 r300
->hw
.vpp
.cmd
[R300_VPP_PARAM_0
+ i
+ 4 * (dest
& 0xff)] = (vsf
->body
.d
[i
]);
1546 bump_vpu_count(r300
->hw
.vpp
.cmd
, vsf
->length
+ 4 * (dest
& 0xff));
1549 R300_STATECHANGE(r300
, vps
);
1550 for (i
= 0; i
< vsf
->length
; i
++)
1551 r300
->hw
.vps
.cmd
[1 + i
+ 4 * (dest
& 0xff)] = (vsf
->body
.d
[i
]);
1552 bump_vpu_count(r300
->hw
.vps
.cmd
, vsf
->length
+ 4 * (dest
& 0xff));
1555 fprintf(stderr
, "%s:%s don't know how to handle dest %04x\n", __FILE__
, __FUNCTION__
, dest
);
1560 static void r300SetupDefaultVertexProgram(r300ContextPtr rmesa
)
1562 struct r300_vertex_shader_state
*prog
= &(rmesa
->state
.vertex_shader
);
1566 int param_count
= 0;
1567 int program_end
= 0;
1569 for (i
= VERT_ATTRIB_POS
; i
< VERT_ATTRIB_MAX
; i
++) {
1570 if (rmesa
->state
.sw_tcl_inputs
[i
] != -1) {
1571 prog
->program
.body
.i
[program_end
+ 0] = EASY_VSF_OP(MUL
, o_reg
++, ALL
, RESULT
);
1572 prog
->program
.body
.i
[program_end
+ 1] = VSF_REG(rmesa
->state
.sw_tcl_inputs
[i
]);
1573 prog
->program
.body
.i
[program_end
+ 2] = VSF_ATTR_UNITY(rmesa
->state
.sw_tcl_inputs
[i
]);
1574 prog
->program
.body
.i
[program_end
+ 3] = VSF_UNITY(rmesa
->state
.sw_tcl_inputs
[i
]);
1579 prog
->program
.length
= program_end
;
1581 r300SetupVertexProgramFragment(rmesa
, R300_PVS_UPLOAD_PROGRAM
,
1583 inst_count
= (prog
->program
.length
/ 4) - 1;
1585 R300_STATECHANGE(rmesa
, pvs
);
1586 rmesa
->hw
.pvs
.cmd
[R300_PVS_CNTL_1
] =
1587 (0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT
) |
1588 (inst_count
<< R300_PVS_CNTL_1_POS_END_SHIFT
) |
1589 (inst_count
<< R300_PVS_CNTL_1_PROGRAM_END_SHIFT
);
1590 rmesa
->hw
.pvs
.cmd
[R300_PVS_CNTL_2
] =
1591 (0 << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT
) |
1592 (param_count
<< R300_PVS_CNTL_2_PARAM_COUNT_SHIFT
);
1593 rmesa
->hw
.pvs
.cmd
[R300_PVS_CNTL_3
] =
1594 (inst_count
<< R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT
) |
1595 (inst_count
<< R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT
);
1598 static void r300SetupRealVertexProgram(r300ContextPtr rmesa
)
1600 GLcontext
*ctx
= rmesa
->radeon
.glCtx
;
1601 struct r300_vertex_program
*prog
= (struct r300_vertex_program
*)CURRENT_VERTEX_SHADER(ctx
);
1603 int param_count
= 0;
1605 /* FIXME: r300SetupVertexProgramFragment */
1606 R300_STATECHANGE(rmesa
, vpp
);
1608 r300VertexProgUpdateParams(ctx
,
1609 (struct r300_vertex_program_cont
*)
1610 ctx
->VertexProgram
._Current
,
1611 (float *)&rmesa
->hw
.vpp
.
1612 cmd
[R300_VPP_PARAM_0
]);
1613 bump_vpu_count(rmesa
->hw
.vpp
.cmd
, param_count
);
1616 r300SetupVertexProgramFragment(rmesa
, R300_PVS_UPLOAD_PROGRAM
, &(prog
->program
));
1617 inst_count
= (prog
->program
.length
/ 4) - 1;
1619 R300_STATECHANGE(rmesa
, pvs
);
1620 rmesa
->hw
.pvs
.cmd
[R300_PVS_CNTL_1
] =
1621 (0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT
) |
1622 (inst_count
<< R300_PVS_CNTL_1_POS_END_SHIFT
) |
1623 (inst_count
<< R300_PVS_CNTL_1_PROGRAM_END_SHIFT
);
1624 rmesa
->hw
.pvs
.cmd
[R300_PVS_CNTL_2
] =
1625 (0 << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT
) |
1626 (param_count
<< R300_PVS_CNTL_2_PARAM_COUNT_SHIFT
);
1627 rmesa
->hw
.pvs
.cmd
[R300_PVS_CNTL_3
] =
1628 (inst_count
<< R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT
) |
1629 (inst_count
<< R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT
);
1632 static void r300SetupVertexProgram(r300ContextPtr rmesa
)
1634 GLcontext
*ctx
= rmesa
->radeon
.glCtx
;
1636 /* Reset state, in case we don't use something */
1637 ((drm_r300_cmd_header_t
*) rmesa
->hw
.vpp
.cmd
)->vpu
.count
= 0;
1638 ((drm_r300_cmd_header_t
*) rmesa
->hw
.vpi
.cmd
)->vpu
.count
= 0;
1639 ((drm_r300_cmd_header_t
*) rmesa
->hw
.vps
.cmd
)->vpu
.count
= 0;
1641 /* Not sure why this doesnt work...
1642 0x400 area might have something to do with pixel shaders as it appears right after pfs programming.
1643 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. */
1644 //setup_vertex_shader_fragment(rmesa, 0x406, &unk4);
1645 if (hw_tcl_on
&& ((struct r300_vertex_program
*)CURRENT_VERTEX_SHADER(ctx
))->translated
) {
1646 r300SetupRealVertexProgram(rmesa
);
1648 /* FIXME: This needs to be replaced by vertex shader generation code. */
1649 r300SetupDefaultVertexProgram(rmesa
);
1653 /* FIXME: This is done for vertex shader fragments, but also needs to be
1654 * done for vap_pvs, so I leave it as a reminder. */
1656 reg_start(R300_VAP_PVS_WAITIDLE
, 0);
1662 * Enable/Disable states.
1664 * \note Mesa already filters redundant calls to this function.
1666 static void r300Enable(GLcontext
* ctx
, GLenum cap
, GLboolean state
)
1668 r300ContextPtr r300
= R300_CONTEXT(ctx
);
1670 if (RADEON_DEBUG
& DEBUG_STATE
)
1671 fprintf(stderr
, "%s( %s = %s )\n", __FUNCTION__
,
1672 _mesa_lookup_enum_by_nr(cap
),
1673 state
? "GL_TRUE" : "GL_FALSE");
1676 /* Fast track this one...
1684 R300_STATECHANGE(r300
, fogs
);
1686 r300
->hw
.fogs
.cmd
[R300_FOGS_STATE
] |= R300_FOG_ENABLE
;
1688 r300Fogfv(ctx
, GL_FOG_MODE
, NULL
);
1689 r300Fogfv(ctx
, GL_FOG_DENSITY
, &ctx
->Fog
.Density
);
1690 r300Fogfv(ctx
, GL_FOG_START
, &ctx
->Fog
.Start
);
1691 r300Fogfv(ctx
, GL_FOG_END
, &ctx
->Fog
.End
);
1692 r300Fogfv(ctx
, GL_FOG_COLOR
, ctx
->Fog
.Color
);
1694 r300
->hw
.fogs
.cmd
[R300_FOGS_STATE
] &= ~R300_FOG_ENABLE
;
1700 r300SetAlphaState(ctx
);
1704 case GL_COLOR_LOGIC_OP
:
1705 r300SetBlendState(ctx
);
1709 case GL_CLIP_PLANE0
:
1710 case GL_CLIP_PLANE1
:
1711 case GL_CLIP_PLANE2
:
1712 case GL_CLIP_PLANE3
:
1713 case GL_CLIP_PLANE4
:
1714 case GL_CLIP_PLANE5
:
1715 /* no VAP UCP on non-TCL chipsets */
1716 if (!(r300
->radeon
.radeonScreen
->chip_flags
& RADEON_CHIPSET_TCL
))
1719 p
= cap
-GL_CLIP_PLANE0
;
1720 R300_STATECHANGE( r300
, vap_clip_cntl
);
1722 r300
->hw
.vap_clip_cntl
.cmd
[1] |= (R300_VAP_UCP_ENABLE_0
<<p
);
1723 r300ClipPlane( ctx
, cap
, NULL
);
1726 r300
->hw
.vap_clip_cntl
.cmd
[1] &= ~(R300_VAP_UCP_ENABLE_0
<<p
);
1730 r300SetDepthState(ctx
);
1733 case GL_STENCIL_TEST
:
1734 if (r300
->state
.stencil
.hw_stencil
) {
1735 R300_STATECHANGE(r300
, zs
);
1737 r300
->hw
.zs
.cmd
[R300_ZS_CNTL_0
] |=
1738 R300_RB3D_STENCIL_ENABLE
;
1740 r300
->hw
.zs
.cmd
[R300_ZS_CNTL_0
] &=
1741 ~R300_RB3D_STENCIL_ENABLE
;
1745 FALLBACK(&r300
->radeon
, RADEON_FALLBACK_STENCIL
, state
);
1751 r300UpdateCulling(ctx
);
1754 case GL_POLYGON_OFFSET_POINT
:
1755 case GL_POLYGON_OFFSET_LINE
:
1756 case GL_POLYGON_OFFSET_FILL
:
1757 R300_STATECHANGE(r300
, occlusion_cntl
);
1759 r300
->hw
.occlusion_cntl
.cmd
[1] |= (3 << 0);
1761 r300
->hw
.occlusion_cntl
.cmd
[1] &= ~(3 << 0);
1767 radeonEnable(ctx
, cap
, state
);
1773 * Completely recalculates hardware state based on the Mesa state.
1775 static void r300ResetHwState(r300ContextPtr r300
)
1777 GLcontext
*ctx
= r300
->radeon
.glCtx
;
1780 if (!(r300
->radeon
.radeonScreen
->chip_flags
& RADEON_CHIPSET_TCL
))
1783 if (RADEON_DEBUG
& DEBUG_STATE
)
1784 fprintf(stderr
, "%s\n", __FUNCTION__
);
1786 r300UpdateWindow(ctx
);
1789 ctx
->Color
.ColorMask
[RCOMP
],
1790 ctx
->Color
.ColorMask
[GCOMP
],
1791 ctx
->Color
.ColorMask
[BCOMP
], ctx
->Color
.ColorMask
[ACOMP
]);
1793 r300Enable(ctx
, GL_DEPTH_TEST
, ctx
->Depth
.Test
);
1794 r300DepthMask(ctx
, ctx
->Depth
.Mask
);
1795 r300DepthFunc(ctx
, ctx
->Depth
.Func
);
1798 r300Enable(ctx
, GL_STENCIL_TEST
, ctx
->Stencil
.Enabled
);
1799 r300StencilMaskSeparate(ctx
, 0, ctx
->Stencil
.WriteMask
[0]);
1800 r300StencilFuncSeparate(ctx
, 0, ctx
->Stencil
.Function
[0],
1801 ctx
->Stencil
.Ref
[0], ctx
->Stencil
.ValueMask
[0]);
1802 r300StencilOpSeparate(ctx
, 0, ctx
->Stencil
.FailFunc
[0],
1803 ctx
->Stencil
.ZFailFunc
[0],
1804 ctx
->Stencil
.ZPassFunc
[0]);
1806 r300UpdateCulling(ctx
);
1808 r300UpdateTextureState(ctx
);
1810 r300SetBlendState(ctx
);
1812 r300AlphaFunc(ctx
, ctx
->Color
.AlphaFunc
, ctx
->Color
.AlphaRef
);
1813 r300Enable(ctx
, GL_ALPHA_TEST
, ctx
->Color
.AlphaEnabled
);
1816 r300
->hw
.vap_cntl
.cmd
[1] = 0x0014045a;
1818 r300
->hw
.vap_cntl
.cmd
[1] = 0x0030045A; //0x0030065a /* Dangerous */
1820 r300
->hw
.vte
.cmd
[1] = R300_VPORT_X_SCALE_ENA
1821 | R300_VPORT_X_OFFSET_ENA
1822 | R300_VPORT_Y_SCALE_ENA
1823 | R300_VPORT_Y_OFFSET_ENA
1824 | R300_VPORT_Z_SCALE_ENA
1825 | R300_VPORT_Z_OFFSET_ENA
| R300_VTX_W0_FMT
;
1826 r300
->hw
.vte
.cmd
[2] = 0x00000008;
1828 r300
->hw
.unk2134
.cmd
[1] = 0x00FFFFFF;
1829 r300
->hw
.unk2134
.cmd
[2] = 0x00000000;
1831 #ifdef MESA_LITTLE_ENDIAN
1832 r300
->hw
.vap_cntl_status
.cmd
[1] = R300_VC_NO_SWAP
;
1834 r300
->hw
.vap_cntl_status
.cmd
[1] = R300_VC_32BIT_SWAP
;
1837 /* disable VAP/TCL on non-TCL capable chips */
1839 r300
->hw
.vap_cntl_status
.cmd
[1] |= R300_VAP_TCL_BYPASS
;
1841 r300
->hw
.unk21DC
.cmd
[1] = 0xAAAAAAAA;
1843 /* XXX: Other families? */
1845 r300
->hw
.vap_clip_cntl
.cmd
[1] = R300_221C_NORMAL
;
1847 r300
->hw
.vap_clip
.cmd
[1] = r300PackFloat32(1.0); /* X */
1848 r300
->hw
.vap_clip
.cmd
[2] = r300PackFloat32(1.0); /* X */
1849 r300
->hw
.vap_clip
.cmd
[3] = r300PackFloat32(1.0); /* Y */
1850 r300
->hw
.vap_clip
.cmd
[4] = r300PackFloat32(1.0); /* Y */
1852 switch (r300
->radeon
.radeonScreen
->chip_family
) {
1853 case CHIP_FAMILY_R300
:
1854 r300
->hw
.unk2288
.cmd
[1] = R300_2288_R300
;
1857 r300
->hw
.unk2288
.cmd
[1] = R300_2288_RV350
;
1862 r300
->hw
.gb_enable
.cmd
[1] = R300_GB_POINT_STUFF_ENABLE
1863 | R300_GB_LINE_STUFF_ENABLE
1864 | R300_GB_TRIANGLE_STUFF_ENABLE
/*| R300_GB_UNK31 */ ;
1866 r300
->hw
.gb_misc
.cmd
[R300_GB_MISC_MSPOS_0
] = 0x66666666;
1867 r300
->hw
.gb_misc
.cmd
[R300_GB_MISC_MSPOS_1
] = 0x06666666;
1869 /* XXX: Other families? */
1870 r300
->hw
.gb_misc
.cmd
[R300_GB_MISC_TILE_CONFIG
] =
1871 R300_GB_TILE_ENABLE
| R300_GB_TILE_SIZE_16
;
1872 switch (r300
->radeon
.radeonScreen
->chip_family
) {
1873 case CHIP_FAMILY_R300
:
1874 case CHIP_FAMILY_R350
:
1875 r300
->hw
.gb_misc
.cmd
[R300_GB_MISC_TILE_CONFIG
] |=
1876 R300_GB_TILE_PIPE_COUNT_R300
;
1878 case CHIP_FAMILY_RV410
:
1879 r300
->hw
.gb_misc
.cmd
[R300_GB_MISC_TILE_CONFIG
] |=
1880 R300_GB_TILE_PIPE_COUNT_RV410
;
1882 case CHIP_FAMILY_R420
:
1883 r300
->hw
.gb_misc
.cmd
[R300_GB_MISC_TILE_CONFIG
] |=
1884 R300_GB_TILE_PIPE_COUNT_R420
;
1887 r300
->hw
.gb_misc
.cmd
[R300_GB_MISC_TILE_CONFIG
] |=
1888 R300_GB_TILE_PIPE_COUNT_RV300
;
1892 /* XXX: set to 0 when fog is disabled? */
1893 r300
->hw
.gb_misc
.cmd
[R300_GB_MISC_SELECT
] = R300_GB_FOG_SELECT_1_1_W
;
1895 /* XXX: Enable anti-aliasing? */
1896 r300
->hw
.gb_misc
.cmd
[R300_GB_MISC_AA_CONFIG
] = R300_AA_DISABLE
;
1898 r300
->hw
.unk4200
.cmd
[1] = r300PackFloat32(0.0);
1899 r300
->hw
.unk4200
.cmd
[2] = r300PackFloat32(0.0);
1900 r300
->hw
.unk4200
.cmd
[3] = r300PackFloat32(1.0);
1901 r300
->hw
.unk4200
.cmd
[4] = r300PackFloat32(1.0);
1903 r300
->hw
.unk4214
.cmd
[1] = 0x00050005;
1905 r300PointSize(ctx
, 1.0);
1907 r300
->hw
.unk4230
.cmd
[1] = 0x18000006;
1908 r300
->hw
.unk4230
.cmd
[2] = 0x00020006;
1909 r300
->hw
.unk4230
.cmd
[3] = r300PackFloat32(1.0 / 192.0);
1911 r300LineWidth(ctx
, 1.0);
1913 r300
->hw
.unk4260
.cmd
[1] = 0;
1914 r300
->hw
.unk4260
.cmd
[2] = r300PackFloat32(0.0);
1915 r300
->hw
.unk4260
.cmd
[3] = r300PackFloat32(1.0);
1917 r300ShadeModel(ctx
, ctx
->Light
.ShadeModel
);
1919 r300PolygonMode(ctx
, GL_FRONT
, ctx
->Polygon
.FrontMode
);
1920 r300PolygonMode(ctx
, GL_BACK
, ctx
->Polygon
.BackMode
);
1921 r300
->hw
.zbias_cntl
.cmd
[1] = 0x00000000;
1923 r300PolygonOffset(ctx
, ctx
->Polygon
.OffsetFactor
,
1924 ctx
->Polygon
.OffsetUnits
);
1925 r300Enable(ctx
, GL_POLYGON_OFFSET_POINT
, ctx
->Polygon
.OffsetPoint
);
1926 r300Enable(ctx
, GL_POLYGON_OFFSET_LINE
, ctx
->Polygon
.OffsetLine
);
1927 r300Enable(ctx
, GL_POLYGON_OFFSET_FILL
, ctx
->Polygon
.OffsetFill
);
1929 r300
->hw
.unk42C0
.cmd
[1] = 0x4B7FFFFF;
1930 r300
->hw
.unk42C0
.cmd
[2] = 0x00000000;
1932 r300
->hw
.unk43A4
.cmd
[1] = 0x0000001C;
1933 r300
->hw
.unk43A4
.cmd
[2] = 0x2DA49525;
1935 r300
->hw
.unk43E8
.cmd
[1] = 0x00FFFFFF;
1937 r300
->hw
.unk46A4
.cmd
[1] = 0x00001B01;
1938 r300
->hw
.unk46A4
.cmd
[2] = 0x00001B0F;
1939 r300
->hw
.unk46A4
.cmd
[3] = 0x00001B0F;
1940 r300
->hw
.unk46A4
.cmd
[4] = 0x00001B0F;
1941 r300
->hw
.unk46A4
.cmd
[5] = 0x00000001;
1943 r300Enable(ctx
, GL_FOG
, ctx
->Fog
.Enabled
);
1944 r300Fogfv(ctx
, GL_FOG_MODE
, NULL
);
1945 r300Fogfv(ctx
, GL_FOG_DENSITY
, &ctx
->Fog
.Density
);
1946 r300Fogfv(ctx
, GL_FOG_START
, &ctx
->Fog
.Start
);
1947 r300Fogfv(ctx
, GL_FOG_END
, &ctx
->Fog
.End
);
1948 r300Fogfv(ctx
, GL_FOG_COLOR
, ctx
->Fog
.Color
);
1949 r300Fogfv(ctx
, GL_FOG_COORDINATE_SOURCE_EXT
, NULL
);
1951 r300
->hw
.unk4BD8
.cmd
[1] = 0;
1953 r300
->hw
.unk4E00
.cmd
[1] = 0;
1955 r300BlendColor(ctx
, ctx
->Color
.BlendColor
);
1957 /* Again, r300ClearBuffer uses this */
1958 r300
->hw
.cb
.cmd
[R300_CB_OFFSET
] =
1959 r300
->radeon
.state
.color
.drawOffset
+
1960 r300
->radeon
.radeonScreen
->fbLocation
;
1961 r300
->hw
.cb
.cmd
[R300_CB_PITCH
] = r300
->radeon
.state
.color
.drawPitch
;
1963 if (r300
->radeon
.radeonScreen
->cpp
== 4)
1964 r300
->hw
.cb
.cmd
[R300_CB_PITCH
] |= R300_COLOR_FORMAT_ARGB8888
;
1966 r300
->hw
.cb
.cmd
[R300_CB_PITCH
] |= R300_COLOR_FORMAT_RGB565
;
1968 if (r300
->radeon
.sarea
->tiling_enabled
)
1969 r300
->hw
.cb
.cmd
[R300_CB_PITCH
] |= R300_COLOR_TILE_ENABLE
;
1971 r300
->hw
.unk4E50
.cmd
[1] = 0;
1972 r300
->hw
.unk4E50
.cmd
[2] = 0;
1973 r300
->hw
.unk4E50
.cmd
[3] = 0;
1974 r300
->hw
.unk4E50
.cmd
[4] = 0;
1975 r300
->hw
.unk4E50
.cmd
[5] = 0;
1976 r300
->hw
.unk4E50
.cmd
[6] = 0;
1977 r300
->hw
.unk4E50
.cmd
[7] = 0;
1978 r300
->hw
.unk4E50
.cmd
[8] = 0;
1979 r300
->hw
.unk4E50
.cmd
[9] = 0;
1981 r300
->hw
.unk4E88
.cmd
[1] = 0;
1983 r300
->hw
.unk4EA0
.cmd
[1] = 0x00000000;
1984 r300
->hw
.unk4EA0
.cmd
[2] = 0xffffffff;
1986 r300
->hw
.zb
.cmd
[R300_ZB_OFFSET
] =
1987 r300
->radeon
.radeonScreen
->depthOffset
+
1988 r300
->radeon
.radeonScreen
->fbLocation
;
1989 r300
->hw
.zb
.cmd
[R300_ZB_PITCH
] = r300
->radeon
.radeonScreen
->depthPitch
;
1991 if (r300
->radeon
.sarea
->tiling_enabled
) {
1992 /* XXX: Turn off when clearing buffers ? */
1993 r300
->hw
.zb
.cmd
[R300_ZB_PITCH
] |= R300_DEPTH_TILE_ENABLE
;
1995 if (ctx
->Visual
.depthBits
== 24)
1996 r300
->hw
.zb
.cmd
[R300_ZB_PITCH
] |=
1997 R300_DEPTH_MICROTILE_ENABLE
;
2000 r300
->hw
.unk4F28
.cmd
[1] = 0;
2002 r300
->hw
.unk4F30
.cmd
[1] = 0;
2003 r300
->hw
.unk4F30
.cmd
[2] = 0;
2005 r300
->hw
.unk4F44
.cmd
[1] = 0;
2007 r300
->hw
.unk4F54
.cmd
[1] = 0;
2010 r300
->hw
.vps
.cmd
[R300_VPS_ZERO_0
] = 0;
2011 r300
->hw
.vps
.cmd
[R300_VPS_ZERO_1
] = 0;
2012 r300
->hw
.vps
.cmd
[R300_VPS_POINTSIZE
] = r300PackFloat32(1.0);
2013 r300
->hw
.vps
.cmd
[R300_VPS_ZERO_3
] = 0;
2016 r300
->hw
.all_dirty
= GL_TRUE
;
2019 void r300UpdateShaders(r300ContextPtr rmesa
)
2022 struct r300_vertex_program
*vp
;
2025 ctx
= rmesa
->radeon
.glCtx
;
2027 if (rmesa
->NewGLState
&& hw_tcl_on
) {
2028 rmesa
->NewGLState
= 0;
2030 for (i
= _TNL_FIRST_MAT
; i
<= _TNL_LAST_MAT
; i
++) {
2031 rmesa
->temp_attrib
[i
] =
2032 TNL_CONTEXT(ctx
)->vb
.AttribPtr
[i
];
2033 TNL_CONTEXT(ctx
)->vb
.AttribPtr
[i
] =
2034 &rmesa
->dummy_attrib
[i
];
2037 _tnl_UpdateFixedFunctionProgram(ctx
);
2039 for (i
= _TNL_FIRST_MAT
; i
<= _TNL_LAST_MAT
; i
++) {
2040 TNL_CONTEXT(ctx
)->vb
.AttribPtr
[i
] =
2041 rmesa
->temp_attrib
[i
];
2044 r300SelectVertexShader(rmesa
);
2045 vp
= (struct r300_vertex_program
*)
2046 CURRENT_VERTEX_SHADER(ctx
);
2047 /*if (vp->translated == GL_FALSE)
2048 r300TranslateVertexShader(vp); */
2049 if (vp
->translated
== GL_FALSE
) {
2050 fprintf(stderr
, "Failing back to sw-tcl\n");
2051 hw_tcl_on
= future_hw_tcl_on
= 0;
2052 r300ResetHwState(rmesa
);
2056 r300UpdateStateParameters(ctx
, _NEW_PROGRAM
);
2060 static void r300SetupPixelShader(r300ContextPtr rmesa
)
2062 GLcontext
*ctx
= rmesa
->radeon
.glCtx
;
2063 struct r300_fragment_program
*fp
= (struct r300_fragment_program
*)
2064 (char *)ctx
->FragmentProgram
._Current
;
2067 if (!fp
) /* should only happenen once, just after context is created */
2070 r300TranslateFragmentShader(rmesa
, fp
);
2071 if (!fp
->translated
) {
2072 fprintf(stderr
, "%s: No valid fragment shader, exiting\n",
2077 R300_STATECHANGE(rmesa
, fpi
[0]);
2078 rmesa
->hw
.fpi
[0].cmd
[R300_FPI_CMD_0
] = cmdpacket0(R300_PFS_INSTR0_0
, fp
->alu_end
+ 1);
2079 for (i
= 0; i
<= fp
->alu_end
; i
++) {
2080 rmesa
->hw
.fpi
[0].cmd
[R300_FPI_INSTR_0
+ i
] = fp
->alu
.inst
[i
].inst0
;
2083 R300_STATECHANGE(rmesa
, fpi
[1]);
2084 rmesa
->hw
.fpi
[1].cmd
[R300_FPI_CMD_0
] = cmdpacket0(R300_PFS_INSTR1_0
, fp
->alu_end
+ 1);
2085 for (i
= 0; i
<= fp
->alu_end
; i
++) {
2086 rmesa
->hw
.fpi
[1].cmd
[R300_FPI_INSTR_0
+ i
] = fp
->alu
.inst
[i
].inst1
;
2089 R300_STATECHANGE(rmesa
, fpi
[2]);
2090 rmesa
->hw
.fpi
[2].cmd
[R300_FPI_CMD_0
] = cmdpacket0(R300_PFS_INSTR2_0
, fp
->alu_end
+ 1);
2091 for (i
= 0; i
<= fp
->alu_end
; i
++) {
2092 rmesa
->hw
.fpi
[2].cmd
[R300_FPI_INSTR_0
+ i
] = fp
->alu
.inst
[i
].inst2
;
2095 R300_STATECHANGE(rmesa
, fpi
[3]);
2096 rmesa
->hw
.fpi
[3].cmd
[R300_FPI_CMD_0
] = cmdpacket0(R300_PFS_INSTR3_0
, fp
->alu_end
+ 1);
2097 for (i
= 0; i
<= fp
->alu_end
; i
++) {
2098 rmesa
->hw
.fpi
[3].cmd
[R300_FPI_INSTR_0
+ i
] = fp
->alu
.inst
[i
].inst3
;
2101 R300_STATECHANGE(rmesa
, fp
);
2102 rmesa
->hw
.fp
.cmd
[R300_FP_CNTL0
] = fp
->cur_node
| (fp
->first_node_has_tex
<< 3);
2103 rmesa
->hw
.fp
.cmd
[R300_FP_CNTL1
] = fp
->max_temp_idx
;
2104 rmesa
->hw
.fp
.cmd
[R300_FP_CNTL2
] =
2105 (fp
->alu_offset
<< R300_PFS_CNTL_ALU_OFFSET_SHIFT
) |
2106 (fp
->alu_end
<< R300_PFS_CNTL_ALU_END_SHIFT
) |
2107 (fp
->tex_offset
<< R300_PFS_CNTL_TEX_OFFSET_SHIFT
) |
2108 (fp
->tex_end
<< R300_PFS_CNTL_TEX_END_SHIFT
);
2109 /* I just want to say, the way these nodes are stored.. weird.. */
2110 for (i
= 0, k
= (4 - (fp
->cur_node
+ 1)); i
< 4; i
++, k
++) {
2111 if (i
< (fp
->cur_node
+ 1)) {
2112 rmesa
->hw
.fp
.cmd
[R300_FP_NODE0
+ k
] =
2113 (fp
->node
[i
].alu_offset
<< R300_PFS_NODE_ALU_OFFSET_SHIFT
) |
2114 (fp
->node
[i
].alu_end
<< R300_PFS_NODE_ALU_END_SHIFT
) |
2115 (fp
->node
[i
].tex_offset
<< R300_PFS_NODE_TEX_OFFSET_SHIFT
) |
2116 (fp
->node
[i
].tex_end
<< R300_PFS_NODE_TEX_END_SHIFT
) |
2119 rmesa
->hw
.fp
.cmd
[R300_FP_NODE0
+ (3 - i
)] = 0;
2123 R300_STATECHANGE(rmesa
, fpp
);
2124 rmesa
->hw
.fpp
.cmd
[R300_FPP_CMD_0
] = cmdpacket0(R300_PFS_PARAM_0_X
, fp
->const_nr
* 4);
2125 for (i
= 0; i
< fp
->const_nr
; i
++) {
2126 rmesa
->hw
.fpp
.cmd
[R300_FPP_PARAM_0
+ 4 * i
+ 0] = r300PackFloat24(fp
->constant
[i
][0]);
2127 rmesa
->hw
.fpp
.cmd
[R300_FPP_PARAM_0
+ 4 * i
+ 1] = r300PackFloat24(fp
->constant
[i
][1]);
2128 rmesa
->hw
.fpp
.cmd
[R300_FPP_PARAM_0
+ 4 * i
+ 2] = r300PackFloat24(fp
->constant
[i
][2]);
2129 rmesa
->hw
.fpp
.cmd
[R300_FPP_PARAM_0
+ 4 * i
+ 3] = r300PackFloat24(fp
->constant
[i
][3]);
2133 void r300UpdateShaderStates(r300ContextPtr rmesa
)
2136 ctx
= rmesa
->radeon
.glCtx
;
2138 r300UpdateTextureState(ctx
);
2140 r300SetupPixelShader(rmesa
);
2141 r300SetupTextures(ctx
);
2143 if ((rmesa
->radeon
.radeonScreen
->chip_flags
& RADEON_CHIPSET_TCL
))
2144 r300SetupVertexProgram(rmesa
);
2145 r300SetupRSUnit(ctx
);
2149 * Called by Mesa after an internal state update.
2151 static void r300InvalidateState(GLcontext
* ctx
, GLuint new_state
)
2153 r300ContextPtr r300
= R300_CONTEXT(ctx
);
2155 _swrast_InvalidateState(ctx
, new_state
);
2156 _swsetup_InvalidateState(ctx
, new_state
);
2157 _vbo_InvalidateState(ctx
, new_state
);
2158 _tnl_InvalidateState(ctx
, new_state
);
2159 _ae_invalidate_state(ctx
, new_state
);
2161 if (new_state
& (_NEW_BUFFERS
| _NEW_COLOR
| _NEW_PIXEL
)) {
2162 r300UpdateDrawBuffer(ctx
);
2165 r300UpdateStateParameters(ctx
, new_state
);
2167 r300
->NewGLState
|= new_state
;
2171 * Calculate initial hardware state and register state functions.
2172 * Assumes that the command buffer and state atoms have been
2173 * initialized already.
2175 void r300InitState(r300ContextPtr r300
)
2177 GLcontext
*ctx
= r300
->radeon
.glCtx
;
2180 radeonInitState(&r300
->radeon
);
2182 switch (ctx
->Visual
.depthBits
) {
2184 r300
->state
.depth
.scale
= 1.0 / (GLfloat
) 0xffff;
2185 depth_fmt
= R300_DEPTH_FORMAT_16BIT_INT_Z
;
2186 r300
->state
.stencil
.clear
= 0x00000000;
2189 r300
->state
.depth
.scale
= 1.0 / (GLfloat
) 0xffffff;
2190 depth_fmt
= R300_DEPTH_FORMAT_24BIT_INT_Z
;
2191 r300
->state
.stencil
.clear
= 0x00ff0000;
2194 fprintf(stderr
, "Error: Unsupported depth %d... exiting\n",
2195 ctx
->Visual
.depthBits
);
2199 /* Only have hw stencil when depth buffer is 24 bits deep */
2200 r300
->state
.stencil
.hw_stencil
= (ctx
->Visual
.stencilBits
> 0 &&
2201 ctx
->Visual
.depthBits
== 24);
2203 memset(&(r300
->state
.texture
), 0, sizeof(r300
->state
.texture
));
2205 r300ResetHwState(r300
);
2208 static void r300RenderMode(GLcontext
* ctx
, GLenum mode
)
2210 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
2215 static void r300ClipPlane( GLcontext
*ctx
, GLenum plane
, const GLfloat
*eq
)
2217 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
2218 GLint p
= (GLint
) plane
- (GLint
) GL_CLIP_PLANE0
;
2219 GLint
*ip
= (GLint
*)ctx
->Transform
._ClipUserPlane
[p
];
2221 R300_STATECHANGE( rmesa
, vpucp
[p
] );
2222 rmesa
->hw
.vpucp
[p
].cmd
[R300_VPUCP_X
] = ip
[0];
2223 rmesa
->hw
.vpucp
[p
].cmd
[R300_VPUCP_Y
] = ip
[1];
2224 rmesa
->hw
.vpucp
[p
].cmd
[R300_VPUCP_Z
] = ip
[2];
2225 rmesa
->hw
.vpucp
[p
].cmd
[R300_VPUCP_W
] = ip
[3];
2229 void r300UpdateClipPlanes( GLcontext
*ctx
)
2231 r300ContextPtr rmesa
= R300_CONTEXT(ctx
);
2234 for (p
= 0; p
< ctx
->Const
.MaxClipPlanes
; p
++) {
2235 if (ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) {
2236 GLint
*ip
= (GLint
*)ctx
->Transform
._ClipUserPlane
[p
];
2238 R300_STATECHANGE( rmesa
, vpucp
[p
] );
2239 rmesa
->hw
.vpucp
[p
].cmd
[R300_VPUCP_X
] = ip
[0];
2240 rmesa
->hw
.vpucp
[p
].cmd
[R300_VPUCP_Y
] = ip
[1];
2241 rmesa
->hw
.vpucp
[p
].cmd
[R300_VPUCP_Z
] = ip
[2];
2242 rmesa
->hw
.vpucp
[p
].cmd
[R300_VPUCP_W
] = ip
[3];
2248 * Initialize driver's state callback functions
2250 void r300InitStateFuncs(struct dd_function_table
*functions
)
2252 radeonInitStateFuncs(functions
);
2254 functions
->UpdateState
= r300InvalidateState
;
2255 functions
->AlphaFunc
= r300AlphaFunc
;
2256 functions
->BlendColor
= r300BlendColor
;
2257 functions
->BlendEquationSeparate
= r300BlendEquationSeparate
;
2258 functions
->BlendFuncSeparate
= r300BlendFuncSeparate
;
2259 functions
->Enable
= r300Enable
;
2260 functions
->ColorMask
= r300ColorMask
;
2261 functions
->DepthFunc
= r300DepthFunc
;
2262 functions
->DepthMask
= r300DepthMask
;
2263 functions
->CullFace
= r300CullFace
;
2264 functions
->Fogfv
= r300Fogfv
;
2265 functions
->FrontFace
= r300FrontFace
;
2266 functions
->ShadeModel
= r300ShadeModel
;
2268 /* Stencil related */
2269 functions
->ClearStencil
= r300ClearStencil
;
2270 functions
->StencilFuncSeparate
= r300StencilFuncSeparate
;
2271 functions
->StencilMaskSeparate
= r300StencilMaskSeparate
;
2272 functions
->StencilOpSeparate
= r300StencilOpSeparate
;
2274 /* Viewport related */
2275 functions
->Viewport
= r300Viewport
;
2276 functions
->DepthRange
= r300DepthRange
;
2277 functions
->PointSize
= r300PointSize
;
2278 functions
->LineWidth
= r300LineWidth
;
2280 functions
->PolygonOffset
= r300PolygonOffset
;
2281 functions
->PolygonMode
= r300PolygonMode
;
2283 functions
->RenderMode
= r300RenderMode
;
2285 functions
->ClipPlane
= r300ClipPlane
;