Skip to contentSkip to conversation

mesa: nouveau/nvfx primitive restart

PATCH In review Patrice Mandin 2 participants 4 messages Nov 13, 2010 – Nov 15, 2010 3 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mesa: nouveau/nvfx primitive restart

Hello,

As nv30/nv40 supports primitive restart in hardware, here is a patch.

I still did not manage to get piglit working to check for correctness, so I would like to know if it's ok as is.

Signature · 6 lines
Patrice Mandin
WWW: http://pmandin.atari.org/
Programmeur Linux, Atari
Spécialité: Développement, jeux

"who writes the code, decides"

From 39edccdb5ac0d72eff8c6d0441028a5e201a002c Mon Sep 17 00:00:00 2001
From: Patrice Mandin <[email protected]>
Date: Sat, 13 Nov 2010 11:07:14 +0100
Subject: [PATCH] nouveau/nvfx: primitive restart support

---
 src/gallium/drivers/nvfx/nv30-40_3d.xml.h |    3 ++-
 src/gallium/drivers/nvfx/nvfx_push.c      |   18 ++++++------------
 src/gallium/drivers/nvfx/nvfx_screen.c    |    2 +-
 3 files changed, 9 insertions(+), 14 deletions(-)
src/gallium/drivers/nvfx/nv30-40_3d.xml.h +2 -1
index a705a6b..3ed3e53 100644
@@ -1942,7 +1942,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define NV30_3D_CLEAR_BUFFERS_COLOR_B				0x00000040
 #define NV30_3D_CLEAR_BUFFERS_COLOR_A				0x00000080
 
-#define NV30_3D_DO_VERTICES					0x00001dac
+#define NV30_3D_PRIMITIVE_RESTART_ENABLE			0x00001dac
+#define NV30_3D_PRIMITIVE_RESTART_INDEX				0x00001db0
 
 #define NV30_3D_LINE_STIPPLE_ENABLE				0x00001db4
 
src/gallium/drivers/nvfx/nvfx_push.c +6 -12
index ebf47e6..eeba225 100644
@@ -337,6 +337,12 @@ nvfx_push_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
 		nvfx_emit_vtx_attr(chan, nvfx->vtxelt->per_instance[i].base.idx, v, nvfx->vtxelt->per_instance[i].base.ncomp);
 	}
 
+	/* Primitive restart */
+	WAIT_RING(chan, 2);
+	OUT_RING(chan, RING_3D(NV30_3D_PRIMITIVE_RESTART_ENABLE, 2));
+	OUT_RING(chan, info->primitive_restart ? 1 : 0);
+	OUT_RING(chan, info->restart_index);
+
 	/* per-instance loop */
 	while (instances_left--) {
 		int max_verts;
@@ -367,18 +373,6 @@ nvfx_push_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
 
 			if(max_verts >= 16)
 			{
-				/* XXX: any command a lot of times seems to (mostly) fix corruption that would otherwise happen */
-				/* this seems to cause issues on nv3x, and also be unneeded there */
-				if(nvfx->is_nv4x)
-				{
-					int i;
-					for(i = 0; i < 32; ++i)
-					{
-						OUT_RING(chan, RING_3D(0x1dac, 1));
-						OUT_RING(chan, 0);
-					}
-				}
-
 				OUT_RING(chan, RING_3D(NV30_3D_VERTEX_BEGIN_END, 1));
 				OUT_RING(chan, hw_mode);
 				done = util_split_prim_next(&s, max_verts);
src/gallium/drivers/nvfx/nvfx_screen.c +1 -1
index 8bf0907..8981377 100644
@@ -78,7 +78,7 @@ nvfx_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
 	case PIPE_CAP_DEPTH_CLAMP:
 		return 0; // TODO: implement depth clamp
 	case PIPE_CAP_PRIMITIVE_RESTART:
-		return 0; // TODO: implement primitive restart
+		return 1;
 	case PIPE_CAP_SHADER_STENCIL_EXPORT:
 		return 0;
 	default:
Signature · 1 line
1.7.2.3

_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): 20101113112006.e161abe1.mandin.patrice-1tsiiZ//[email protected]

#2 lore raw
Quoted 4 lines · Patrice Mandin

Hello,

As nv30/nv40 supports primitive restart in hardware, here is a patch.

Thank you, note however that this does not make it work yet in the case where the driver decides to push vertex data on the FIFO directly, which is implemented via the translate module and u_split_prim in nvfx_push.c, maybe you could adjust that path too ?

Cheers,
Christoph

Quoted 9 lines

I still did not manage to get piglit working to check for correctness, so I would like to know if it's ok as is.

_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

_______________________________________________
Nouveau mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): 4CDE7936.6040309-oe7qfRrRQffzPE21tAIdciO7C/[email protected]

#4 lore raw
Quoted 9 lines · Le Sat, 13 Nov 2010 12:40:38 +0100 Christoph Bumiller…
Quoted 4 lines · Patrice Mandin

Hello,

As nv30/nv40 supports primitive restart in hardware, here is a patch.

Thank you, note however that this does not make it work yet in the case where the driver decides to push vertex data on the FIFO directly, which is implemented via the translate module and u_split_prim in nvfx_push.c, maybe you could adjust that path too ?

Of course, I was also wondering if there were any other code paths that may need to be fixed.

Signature · 6 lines
Patrice Mandin
WWW: http://pmandin.atari.org/
Programmeur Linux, Atari
Spécialité: Développement, jeux

"who writes the code, decides"

A message that is not in the archive (sent off-list or not yet received): 20101113152651.6d098db7.mandin.patrice-1tsiiZ//[email protected]

#6 lore raw
Quoted 8 lines · Le Sat, 13 Nov 2010 15:26:51 +0100 Patrice Mandin…
Quoted 5 lines · Le Sat, 13 Nov 2010 12:40:38 +0100 Christoph Bumiller…
Quoted 4 lines · Patrice Mandin

Hello,

As nv30/nv40 supports primitive restart in hardware, here is a patch.

Quoted 7 lines
Quoted 4 lines

Thank you, note however that this does not make it work yet in the case where the driver decides to push vertex data on the FIFO directly, which is implemented via the translate module and u_split_prim in nvfx_push.c, maybe you could adjust that path too ?

Of course, I was also wondering if there were any other code paths that may need to be fixed.

After having rewritten a bit the test in renouveau, my patch appears to be wrong.

I found a bit of early announcements about nv30 chips that talk about a vertex cache. Luca Barbieri thought 0x1710 could be some kind of vertex cache flush (see http://people.freedesktop.org/~cbrill/dri-log/dri-devel-2010-01-14.log
(at 18:50)).

0x1dac that I changed recently, thinking it could be PRIMITIVE_RESTART_ENABLE, could be a VERTEX_CACHE_ENABLE instead.

When using a vbo, the blob always resend vertex data when primitive_restart is used, even when using an array of indices (which could contain the primitive_restart index, set with 0x1db0).

Signature · 6 lines
Patrice Mandin
WWW: http://pmandin.atari.org/
Programmeur Linux, Atari
Spécialité: Développement, jeux

"who writes the code, decides"