On Feb 5, 2008 9:18 AM, Brian Paul <[EMAIL PROTECTED]> wrote:
> Erkin Bahceci wrote:
> > Hi,
> >
> > Is there any chance for the glClipPlane fix to make it into Mesa 7.0.3?
> > The bug report is here:
> > http://bugs.freedesktop.org/show_bug.cgi?id=9871
> >
> > I suppose the fix consists of these 2 commits:
> > http://gitweb.freedesktop.org/?p=mesa/mesa.git;a=commit;h=35d28ce12e59526cb66e82d7d5469e50196a8ccd
> >
> > http://gitweb.freedesktop.org/?p=mesa/mesa.git;a=commit;h=cd59600c7b6cba42baba208e74d783fbade93356
>
> Can you try out those changes yourself to verify?  If so, I'll
> cherry-pick them into 7.0.3.
>


Ok, I applied the patches, and tried it out. It fixed the issue,
glClipPlane now works as expected without any other problems (as far
as I tested).

The fix needs this change as well:
http://gitweb.freedesktop.org/?p=mesa/mesa.git;a=commit;h=4013382ea2ab08b7904ad908f7b66d2a737b59da

While cherry-picking these 3 commits, you might need to do some manual
merging. I attached the patch against Mesa-7.0.3-rc1 that I ended up
with.

Regards,
Erkin
diff -up -r Mesa-7.0.3-rc1.orig/src/mesa/drivers/dri/r300/r300_cmdbuf.c Mesa-7.0.3-rc1/src/mesa/drivers/dri/r300/r300_cmdbuf.c
--- Mesa-7.0.3-rc1.orig/src/mesa/drivers/dri/r300/r300_cmdbuf.c	2008-02-05 23:23:45.000000000 -0600
+++ Mesa-7.0.3-rc1/src/mesa/drivers/dri/r300/r300_cmdbuf.c	2008-02-05 22:42:50.000000000 -0600
@@ -316,8 +316,8 @@ void r300InitCmdBuf(r300ContextPtr r300)
 	r300->hw.vic.cmd[R300_VIC_CMD_0] = cmdpacket0(R300_VAP_INPUT_CNTL_0, 2);
 	ALLOC_STATE(unk21DC, always, 2, 0);
 	r300->hw.unk21DC.cmd[0] = cmdpacket0(0x21DC, 1);
-	ALLOC_STATE(unk221C, always, 2, 0);
-	r300->hw.unk221C.cmd[0] = cmdpacket0(R300_VAP_UNKNOWN_221C, 1);
+	ALLOC_STATE(vap_clip_cntl, always, 2, 0);
+	r300->hw.vap_clip_cntl.cmd[0] = cmdpacket0(R300_VAP_CLIP_CNTL, 1);
 	ALLOC_STATE(unk2220, always, 5, 0);
 	r300->hw.unk2220.cmd[0] = cmdpacket0(0x2220, 4);
 	ALLOC_STATE(unk2288, always, 2, 0);
@@ -438,15 +438,24 @@ void r300InitCmdBuf(r300ContextPtr r300)
 
 	/* VPU only on TCL */
 	if (has_tcl) {
+   	        int i;
 		ALLOC_STATE(vpi, vpu, R300_VPI_CMDSIZE, 0);
 		r300->hw.vpi.cmd[R300_VPI_CMD_0] =
 		    cmdvpu(R300_PVS_UPLOAD_PROGRAM, 0);
+
 		ALLOC_STATE(vpp, vpu, R300_VPP_CMDSIZE, 0);
 		r300->hw.vpp.cmd[R300_VPP_CMD_0] =
 		    cmdvpu(R300_PVS_UPLOAD_PARAMETERS, 0);
+
 		ALLOC_STATE(vps, vpu, R300_VPS_CMDSIZE, 0);
 		r300->hw.vps.cmd[R300_VPS_CMD_0] =
 		    cmdvpu(R300_PVS_UPLOAD_POINTSIZE, 1);
+
+		for (i = 0; i < 6; i++) {
+		  ALLOC_STATE(vpucp[i], vpu, R300_VPUCP_CMDSIZE, 0);
+		  r300->hw.vpucp[i].cmd[R300_VPUCP_CMD_0] =
+ 		    cmdvpu(R300_PVS_UPLOAD_CLIP_PLANE0+i, 1);
+		}
 	}
 
 	/* Textures */
diff -up -r Mesa-7.0.3-rc1.orig/src/mesa/drivers/dri/r300/r300_context.h Mesa-7.0.3-rc1/src/mesa/drivers/dri/r300/r300_context.h
--- Mesa-7.0.3-rc1.orig/src/mesa/drivers/dri/r300/r300_context.h	2008-02-05 23:23:45.000000000 -0600
+++ Mesa-7.0.3-rc1/src/mesa/drivers/dri/r300/r300_context.h	2008-02-05 22:43:31.000000000 -0600
@@ -421,6 +421,13 @@ struct r300_state_atom {
 #define R300_VPP_PARAM_0	1
 #define R300_VPP_CMDSIZE	1025	/* 256 4-component parameters */
 
+#define R300_VPUCP_CMD_0		0
+#define R300_VPUCP_X            1
+#define R300_VPUCP_Y            2
+#define R300_VPUCP_Z            3
+#define R300_VPUCP_W            4
+#define R300_VPUCP_CMDSIZE	5	/* 256 4-component parameters */
+
 #define R300_VPS_CMD_0		0
 #define R300_VPS_ZERO_0		1
 #define R300_VPS_ZERO_1		2
@@ -454,7 +461,7 @@ struct r300_hw_state {
 	struct r300_state_atom vir[2];	/* vap input route (2150/21E0) */
 	struct r300_state_atom vic;	/* vap input control (2180) */
 	struct r300_state_atom unk21DC;	/* (21DC) */
-	struct r300_state_atom unk221C;	/* (221C) */
+	struct r300_state_atom vap_clip_cntl;
 	struct r300_state_atom unk2220;	/* (2220) */
 	struct r300_state_atom unk2288;	/* (2288) */
 	struct r300_state_atom pvs;	/* pvs_cntl (22D0) */
@@ -508,6 +515,7 @@ struct r300_hw_state {
 	struct r300_state_atom vpi;	/* vp instructions */
 	struct r300_state_atom vpp;	/* vp parameters */
 	struct r300_state_atom vps;	/* vertex point size (?) */
+	struct r300_state_atom vpucp[6];	/* vp user clip plane - 6 */
 	/* 8 texture units */
 	/* the state is grouped by function and not by
 	   texture unit. This makes single unit updates
diff -up -r Mesa-7.0.3-rc1.orig/src/mesa/drivers/dri/r300/r300_ioctl.c Mesa-7.0.3-rc1/src/mesa/drivers/dri/r300/r300_ioctl.c
--- Mesa-7.0.3-rc1.orig/src/mesa/drivers/dri/r300/r300_ioctl.c	2008-02-05 23:23:45.000000000 -0600
+++ Mesa-7.0.3-rc1/src/mesa/drivers/dri/r300/r300_ioctl.c	2008-02-05 22:44:59.000000000 -0600
@@ -266,8 +266,8 @@ static void r300EmitClearState(GLcontext
 	e32(0x0);
 	e32(0x0);
 
-	R300_STATECHANGE(r300, unk221C);
-	reg_start(R300_VAP_UNKNOWN_221C, 0);
+	R300_STATECHANGE(r300, vap_clip_cntl);
+	reg_start(R300_VAP_CLIP_CNTL, 0);
 	e32(R300_221C_CLEAR);
 
 	R300_STATECHANGE(r300, ps);
diff -up -r Mesa-7.0.3-rc1.orig/src/mesa/drivers/dri/r300/r300_reg.h Mesa-7.0.3-rc1/src/mesa/drivers/dri/r300/r300_reg.h
--- Mesa-7.0.3-rc1.orig/src/mesa/drivers/dri/r300/r300_reg.h	2008-02-05 23:23:45.000000000 -0600
+++ Mesa-7.0.3-rc1/src/mesa/drivers/dri/r300/r300_reg.h	2008-02-05 23:06:19.000000000 -0600
@@ -281,8 +281,21 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define R300_VAP_PVS_UPLOAD_ADDRESS         0x2200
 #       define R300_PVS_UPLOAD_PROGRAM           0x00000000
 #       define R300_PVS_UPLOAD_PARAMETERS        0x00000200
+#       define R300_PVS_UPLOAD_CLIP_PLANE0       0x00000400
+#       define R300_PVS_UPLOAD_CLIP_PLANE1       0x00000401
+#       define R300_PVS_UPLOAD_CLIP_PLANE2       0x00000402
+#       define R300_PVS_UPLOAD_CLIP_PLANE3       0x00000403
+#       define R300_PVS_UPLOAD_CLIP_PLANE4       0x00000404
+#       define R300_PVS_UPLOAD_CLIP_PLANE5       0x00000405
 #       define R300_PVS_UPLOAD_POINTSIZE         0x00000406
 
+#       define R500_PVS_UPLOAD_CLIP_PLANE0       0x00000600
+#       define R500_PVS_UPLOAD_CLIP_PLANE1       0x00000601
+#       define R500_PVS_UPLOAD_CLIP_PLANE2       0x00000602
+#       define R500_PVS_UPLOAD_CLIP_PLANE3       0x00000603
+#       define R500_PVS_UPLOAD_CLIP_PLANE4       0x00000604
+#       define R500_PVS_UPLOAD_CLIP_PLANE5       0x00000605
+
 /* gap */
 
 #define R300_VAP_PVS_UPLOAD_DATA            0x2208
@@ -294,10 +307,16 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 /* I do not know the purpose of this register. However, I do know that
  * it is set to 221C_CLEAR for clear operations and to 221C_NORMAL
  * for normal rendering.
+ *
+ * 2007-11-05: This register is the user clip plane control register, but there
+ * also seems to be a rendering mode control; the NORMAL/CLEAR defines.
+ *
+ * See bug #9871. http://bugs.freedesktop.org/attachment.cgi?id=10672&action=view
  */
-#define R300_VAP_UNKNOWN_221C               0x221C
+#define R300_VAP_CLIP_CNTL                       0x221C
 #       define R300_221C_NORMAL                  0x00000000
 #       define R300_221C_CLEAR                   0x0001C000
+#define R300_VAP_UCP_ENABLE_0 (1 << 0)
 
 /* gap */
 
diff -up -r Mesa-7.0.3-rc1.orig/src/mesa/drivers/dri/r300/r300_state.c Mesa-7.0.3-rc1/src/mesa/drivers/dri/r300/r300_state.c
--- Mesa-7.0.3-rc1.orig/src/mesa/drivers/dri/r300/r300_state.c	2008-02-05 23:23:45.000000000 -0600
+++ Mesa-7.0.3-rc1/src/mesa/drivers/dri/r300/r300_state.c	2008-02-05 23:04:44.000000000 -0600
@@ -462,6 +462,8 @@ static void r300SetDepthState(GLcontext 
 	r300SetEarlyZState(ctx);
 }
 
+static void r300ClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *eq );
+
 /**
  * Handle glEnable()/glDisable().
  *
@@ -470,7 +472,7 @@ static void r300SetDepthState(GLcontext 
 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),
@@ -510,6 +512,27 @@ static void r300Enable(GLcontext * ctx, 
 		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, vap_clip_cntl );
+		if (state) {
+			r300->hw.vap_clip_cntl.cmd[1] |= (R300_VAP_UCP_ENABLE_0<<p);
+			r300ClipPlane( ctx, cap, NULL );
+		}
+		else {
+			r300->hw.vap_clip_cntl.cmd[1] &= ~(R300_VAP_UCP_ENABLE_0<<p);
+		}
+		break;
 	case GL_DEPTH_TEST:
 		r300SetDepthState(ctx);
 		break;
@@ -1888,7 +1911,7 @@ static void r300ResetHwState(r300Context
 
 	r300->hw.unk21DC.cmd[1] = 0xAAAAAAAA;
 
-	r300->hw.unk221C.cmd[1] = R300_221C_NORMAL;
+	r300->hw.vap_clip_cntl.cmd[1] = R300_221C_NORMAL;
 
 	r300->hw.unk2220.cmd[1] = r300PackFloat32(1.0);
 	r300->hw.unk2220.cmd[2] = r300PackFloat32(1.0);
@@ -2254,6 +2277,8 @@ void r300InitState(r300ContextPtr r300)
 		depth_fmt = R300_DEPTH_FORMAT_24BIT_INT_Z;
 		r300->state.stencil.clear = 0x00ff0000;
 		break;
+
+
 	default:
 		fprintf(stderr, "Error: Unsupported depth %d... exiting\n",
 			ctx->Visual.depthBits);
@@ -2276,6 +2301,38 @@ static void r300RenderMode(GLcontext * c
 	(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
  */
@@ -2313,4 +2370,6 @@ void r300InitStateFuncs(struct dd_functi
 	functions->PolygonMode = r300PolygonMode;
 
 	functions->RenderMode = r300RenderMode;
+
+	functions->ClipPlane = r300ClipPlane;
 }

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to