summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/r300/r300_state.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@linux.ie>2007-11-04 15:02:55 +1100
committerOliver McFadden <z3ro.geek@gmail.com>2007-11-05 22:17:34 +0000
commit35d28ce12e59526cb66e82d7d5469e50196a8ccd (patch)
treec238f165de5421719956a19f0127f2561009bd54 /src/mesa/drivers/dri/r300/r300_state.c
parent8e66c3d7552bf33163bb8ac2a6d3963bad1b0eb4 (diff)
r300: initial user clipping for TCL paths
I've no idea if this code might break something or how it should interact with vertex shaders, it makes the clip demo work for me
Diffstat (limited to 'src/mesa/drivers/dri/r300/r300_state.c')
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c60
1 files changed, 59 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
index 8a2ebbf959..cd8bcdb47d 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -67,6 +67,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
extern int future_hw_tcl_on;
extern void _tnl_UpdateFixedFunctionProgram(GLcontext * ctx);
+static void r300ClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *eq );
static void r300BlendColor(GLcontext * ctx, const GLfloat cf[4])
{
@@ -1665,7 +1666,7 @@ static void r300SetupVertexProgram(r300ContextPtr rmesa)
static void r300Enable(GLcontext * ctx, GLenum cap, GLboolean state)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
-
+ GLuint p;
if (RADEON_DEBUG & DEBUG_STATE)
fprintf(stderr, "%s( %s = %s )\n", __FUNCTION__,
_mesa_lookup_enum_by_nr(cap),
@@ -1704,6 +1705,27 @@ static void r300Enable(GLcontext * ctx, GLenum cap, GLboolean state)
r300SetBlendState(ctx);
break;
+
+ case GL_CLIP_PLANE0:
+ case GL_CLIP_PLANE1:
+ case GL_CLIP_PLANE2:
+ case GL_CLIP_PLANE3:
+ case GL_CLIP_PLANE4:
+ case GL_CLIP_PLANE5:
+ /* no VAP UCP on non-TCL chipsets */
+ if (!(r300->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL))
+ return;
+
+ p = cap-GL_CLIP_PLANE0;
+ R300_STATECHANGE( r300, unk221C );
+ if (state) {
+ r300->hw.unk221C.cmd[1] |= (R300_VAP_UCP_ENABLE_0<<p);
+ r300ClipPlane( ctx, cap, NULL );
+ }
+ else {
+ r300->hw.unk221C.cmd[1] &= ~(R300_VAP_UCP_ENABLE_0<<p);
+ }
+ break;
case GL_DEPTH_TEST:
r300SetDepthState(ctx);
break;
@@ -1739,6 +1761,8 @@ static void r300Enable(GLcontext * ctx, GLenum cap, GLboolean state)
r300->hw.occlusion_cntl.cmd[1] &= ~(3 << 0);
}
break;
+
+
default:
radeonEnable(ctx, cap, state);
return;
@@ -2188,6 +2212,38 @@ static void r300RenderMode(GLcontext * ctx, GLenum mode)
(void)mode;
}
+static void r300ClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *eq )
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ GLint p = (GLint) plane - (GLint) GL_CLIP_PLANE0;
+ GLint *ip = (GLint *)ctx->Transform._ClipUserPlane[p];
+
+ R300_STATECHANGE( rmesa, vpucp[p] );
+ rmesa->hw.vpucp[p].cmd[R300_VPUCP_X] = ip[0];
+ rmesa->hw.vpucp[p].cmd[R300_VPUCP_Y] = ip[1];
+ rmesa->hw.vpucp[p].cmd[R300_VPUCP_Z] = ip[2];
+ rmesa->hw.vpucp[p].cmd[R300_VPUCP_W] = ip[3];
+}
+
+
+void r300UpdateClipPlanes( GLcontext *ctx )
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ GLuint p;
+
+ for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
+ if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
+ GLint *ip = (GLint *)ctx->Transform._ClipUserPlane[p];
+
+ R300_STATECHANGE( rmesa, vpucp[p] );
+ rmesa->hw.vpucp[p].cmd[R300_VPUCP_X] = ip[0];
+ rmesa->hw.vpucp[p].cmd[R300_VPUCP_Y] = ip[1];
+ rmesa->hw.vpucp[p].cmd[R300_VPUCP_Z] = ip[2];
+ rmesa->hw.vpucp[p].cmd[R300_VPUCP_W] = ip[3];
+ }
+ }
+}
+
/**
* Initialize driver's state callback functions
*/
@@ -2225,4 +2281,6 @@ void r300InitStateFuncs(struct dd_function_table *functions)
functions->PolygonMode = r300PolygonMode;
functions->RenderMode = r300RenderMode;
+
+ functions->ClipPlane = r300ClipPlane;
}