Skip to contentSkip to conversation

nv50/gallium: a few patches, updated

PATCH Christoph Bumiller 1 participant 1 message Jul 28, 2009

lore
Share & tools
lore
#0 lore raw

Half of them I sent previously, now with updated reg names and corrections, the other half is new. Read them for a description, I'm too tired now for detailed explanations ...

Christoph

From 4a2fe7e7e3dd3f7dcb1451f6ee74038897c6df7a Mon Sep 17 00:00:00 2001
From: Christoph Bumiller <e0425955-oe7qfRrRQffzPE21tAIdciO7C/[email protected]>
Date: Wed, 29 Jul 2009 00:35:12 +0200
Subject: [PATCH 1/8] nv50: use correct scissor reg

---
 src/gallium/drivers/nv50/nv50_screen.c         |    4 ++++
 src/gallium/drivers/nv50/nv50_state_validate.c |   23 ++++++++++++++++-------
 2 files changed, 20 insertions(+), 7 deletions(-)
src/gallium/drivers/nv50/nv50_screen.c +4 -0
index ce8f906..349619d 100644
@@ -417,6 +417,10 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
 	so_method(so, screen->tesla, 0x1234, 1);
 	so_data  (so, 1);
 
+	/* activate first scissor rectangle */
+	so_method(so, screen->tesla, NV50TCL_SCISSOR_ENABLE, 1);
+	so_data  (so, 1);
+
 	so_emit(chan, so);
 	so_ref (so, &screen->static_init);
 	so_ref (NULL, &so);
src/gallium/drivers/nv50/nv50_state_validate.c +16 -7
index d313e9d..03aed81 100644
@@ -119,12 +119,18 @@ nv50_state_validate_fb(struct nv50_context *nv50)
 	so_method(so, tesla, NV50TCL_VIEWPORT_HORIZ, 2);
 	so_data  (so, w << 16);
 	so_data  (so, h << 16);
-	so_method(so, tesla, 0x0e04, 2);
+	/* set window scissor rectangle to window extents */
+	so_method(so, tesla, NV50TCL_SCISSOR_HORIZ, 2);
 	so_data  (so, w << 16);
 	so_data  (so, h << 16);
-	so_method(so, tesla, 0xdf8, 2);
+	/* set window lower left corner */
+	so_method(so, tesla, NV50TCL_WINDOW_LEFT, 2);
 	so_data  (so, 0);
 	so_data  (so, h);
+	/* set screen scissor rectangle */
+	so_method(so, tesla, NV50TCL_SCREEN_SCISSOR_HORIZ, 2);
+	so_data  (so, w << 16);
+	so_data  (so, h << 16);
 
 	so_ref(so, &nv50->state.fb);
 	so_ref(NULL, &so);
@@ -233,13 +239,16 @@ nv50_state_validate(struct nv50_context *nv50)
 		nv50->state.scissor_enabled = rast->scissor;
 
 		so = so_new(3, 0);
-		so_method(so, tesla, 0x0ff4, 2);
+		so_method(so, tesla, NV50TCL_SCISSOR_HORIZ, 2);
 		if (nv50->state.scissor_enabled) {
-			so_data(so, ((s->maxx - s->minx) << 16) | s->minx);
-			so_data(so, ((s->maxy - s->miny) << 16) | s->miny);
+			/* the hw has y = 0 = bottom here */
+			unsigned top = nv50->framebuffer.height - s->miny;
+			unsigned bottom = nv50->framebuffer.height - s->maxy;
+			so_data(so, (s->maxx << 16) | s->minx);
+			so_data(so, (top << 16) | bottom);
 		} else {
-			so_data(so, (8192 << 16));
-			so_data(so, (8192 << 16));
+			so_data(so, (nv50->framebuffer.width << 16));
+			so_data(so, (nv50->framebuffer.height << 16));
 		}
 		so_ref(so, &nv50->state.scissor);
 		so_ref(NULL, &so);
Signature · 1 line
1.6.3.3

From 17b8672f7f32015e58006384c8cdb14eddc05491 Mon Sep 17 00:00:00 2001
From: Christoph Bumiller <e0425955-oe7qfRrRQffzPE21tAIdciO7C/[email protected]>
Date: Wed, 29 Jul 2009 01:21:41 +0200
Subject: [PATCH 2/8] nv50: fix viewport transform

The translation also needs to be inverted, and in bypass mode the state tracker incorrectly assumes that Y = 0 = TOP, so we need inversion there to; NDC clipping has to be deactivated explicitly.

---
 src/gallium/drivers/nv50/nv50_state_validate.c |   31 +++++++++++++++--------
 1 files changed, 20 insertions(+), 11 deletions(-)
src/gallium/drivers/nv50/nv50_state_validate.c +20 -11
index 03aed81..ce8e44f 100644
@@ -258,6 +258,7 @@ scissor_uptodate:
 
 	if (nv50->dirty & (NV50_NEW_VIEWPORT | NV50_NEW_RASTERIZER)) {
 		unsigned bypass;
+		float y_translate = (float)nv50->framebuffer.height;
 
 		if (!nv50->rasterizer->pipe.bypass_vs_clip_and_viewport)
 			bypass = 0;
@@ -271,25 +272,33 @@ scissor_uptodate:
 		nv50->state.viewport_bypass = bypass;
 
 		so = so_new(12, 0);
+		so_method(so, tesla, NV50TCL_VIEW_VOLUME_CLIP_CTRL, 1);
 		if (!bypass) {
-			so_method(so, tesla, NV50TCL_VIEWPORT_UNK1(0), 3);
+			so_data(so, 0x0000);
+			y_translate -= nv50->viewport.translate[1];
+			so_method(so, tesla, NV50TCL_VIEWPORT_TRANSLATE(0), 3);
 			so_data  (so, fui(nv50->viewport.translate[0]));
-			so_data  (so, fui(nv50->viewport.translate[1]));
+			so_data  (so, fui(y_translate));
 			so_data  (so, fui(nv50->viewport.translate[2]));
-			so_method(so, tesla, NV50TCL_VIEWPORT_UNK0(0), 3);
+			so_method(so, tesla, NV50TCL_VIEWPORT_SCALE(0), 3);
 			so_data  (so, fui(nv50->viewport.scale[0]));
 			so_data  (so, fui(-nv50->viewport.scale[1]));
 			so_data  (so, fui(nv50->viewport.scale[2]));
-			so_method(so, tesla, 0x192c, 1);
-			so_data  (so, 1);
-			so_method(so, tesla, 0x0f90, 1);
-			so_data  (so, 0);
 		} else {
-			so_method(so, tesla, 0x192c, 1);
-			so_data  (so, 0);
-			so_method(so, tesla, 0x0f90, 1);
-			so_data  (so, 1);
+			/* don't do xy-clipping in NDC space */
+			so_data(so, 0x0800);
+			/* in bypass mode, y = 0 would be bottom */
+			so_method(so, tesla, NV50TCL_VIEWPORT_TRANSLATE(0), 3);
+			so_data  (so, fui(0.0f));
+			so_data  (so, fui(y_translate));
+			so_data  (so, fui(0.0f));
+			so_method(so, tesla, NV50TCL_VIEWPORT_SCALE(0), 3);
+			so_data  (so, fui(1.0f));
+			so_data  (so, fui(-1.0f));
+			so_data  (so, fui(1.0f));
 		}
+		so_method(so, tesla, NV50TCL_VIEWPORT_TRANSFORM_EN, 1);
+		so_data  (so, 1);
 
 		so_ref(so, &nv50->state.viewport);
 		so_ref(NULL, &so);
Signature · 1 line
1.6.3.3

From 3c0ae2090315103b380fbf7f458386c74621ebbd Mon Sep 17 00:00:00 2001
From: Christoph Bumiller <e0425955-oe7qfRrRQffzPE21tAIdciO7C/[email protected]>
Date: Wed, 29 Jul 2009 00:51:35 +0200
Subject: [PATCH 3/8] nv50: fix sx/dx typo in transfer_rect_m2mf

---
 src/gallium/drivers/nv50/nv50_transfer.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
src/gallium/drivers/nv50/nv50_transfer.c +2 -2
index d0b7f0b..6ff3759 100644
@@ -76,13 +76,13 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct nouveau_bo *src_bo,
 		OUT_RELOCl(chan, dst_bo, dst_offset, dst_reloc);
 		if (src_bo->tile_flags) {
 			BEGIN_RING(chan, m2mf, 0x0218, 1);
-			OUT_RING  (chan, (dy << 16) | sx);
+			OUT_RING  (chan, (sy << 16) | sx);
 		} else {
 			src_offset += (line_count * src_pitch);
 		}
 		if (dst_bo->tile_flags) {
 			BEGIN_RING(chan, m2mf, 0x0234, 1);
-			OUT_RING  (chan, (sy << 16) | dx);
+			OUT_RING  (chan, (dy << 16) | dx);
 		} else {
 			dst_offset += (line_count * dst_pitch);
 		}
Signature · 1 line
1.6.3.3

From 25287680e645714f457aedec6fb7a054f8c07ad9 Mon Sep 17 00:00:00 2001
From: Christoph Bumiller <e0425955-oe7qfRrRQffzPE21tAIdciO7C/[email protected]>
Date: Wed, 29 Jul 2009 00:55:03 +0200
Subject: [PATCH 4/8] nv50: TIC/TSC fixes and additions

Red and blue were interchanged in TIC.
Add border color and some formats.

---
 src/gallium/drivers/nv50/nv50_state.c   |    7 +++-
 src/gallium/drivers/nv50/nv50_tex.c     |   16 ++++----
 src/gallium/drivers/nv50/nv50_texture.h |   71 ++++++++++++++++++++-----------
 3 files changed, 60 insertions(+), 34 deletions(-)
src/gallium/drivers/nv50/nv50_state.c +6 -1
index 116866a..c93694c 100644
@@ -205,11 +205,16 @@ nv50_sampler_state_create(struct pipe_context *pipe,
 	}
 
 	limit = CLAMP(cso->lod_bias, -16.0, 15.0);
-	tsc[1] |= ((int)(limit * 256.0) & 0x1fff) << 11;
+	tsc[1] |= ((int)(limit * 256.0) & 0x1fff) << 12;
 
 	tsc[2] |= ((int)CLAMP(cso->max_lod, 0.0, 15.0) << 20) |
 		  ((int)CLAMP(cso->min_lod, 0.0, 15.0) << 8);
 
+	tsc[4] = fui(cso->border_color[0]);
+	tsc[5] = fui(cso->border_color[1]);
+	tsc[6] = fui(cso->border_color[2]);
+	tsc[7] = fui(cso->border_color[3]);
+
 	sso->normalized = cso->normalized_coords;
 	return (void *)sso;
 }
src/gallium/drivers/nv50/nv50_tex.c +8 -8
index ff40c2a..46c3073 100644
@@ -32,30 +32,30 @@ nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so,
 	switch (mt->base.format) {
 	case PIPE_FORMAT_A8R8G8B8_UNORM:
 		so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
-			    NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
+			    NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
 			    NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
-			    NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEB_UNORM |
+			    NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM |
 			    NV50TIC_0_0_FMT_8_8_8_8);
 		break;
 	case PIPE_FORMAT_A1R5G5B5_UNORM:
 		so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
-			    NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
+			    NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
 			    NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
-			    NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEB_UNORM |
+			    NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM |
 			    NV50TIC_0_0_FMT_1_5_5_5);
 		break;
 	case PIPE_FORMAT_A4R4G4B4_UNORM:
 		so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM |
-			    NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
+			    NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
 			    NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
-			    NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEB_UNORM |
+			    NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM |
 			    NV50TIC_0_0_FMT_4_4_4_4);
 		break;
 	case PIPE_FORMAT_R5G6B5_UNORM:
 		so_data(so, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM |
-			    NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM |
+			    NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM |
 			    NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM |
-			    NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEB_UNORM |
+			    NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM |
 			    NV50TIC_0_0_FMT_5_6_5);
 		break;
 	case PIPE_FORMAT_L8_UNORM:
src/gallium/drivers/nv50/nv50_texture.h +46 -25

113 lines not on this page · raw message

Signature · 1 line
1.6.3.3

From d72930b4d92441f2c8d4c11137db3253195578a0 Mon Sep 17 00:00:00 2001
From: Christoph Bumiller <e0425955-oe7qfRrRQffzPE21tAIdciO7C/[email protected]>
Date: Tue, 28 Jul 2009 17:21:31 +0200
Subject: [PATCH 5/8] nv50: should use uint32_t ptr in draw_elements_inline_u32

---
 src/gallium/drivers/nv50/nv50_vbo.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
src/gallium/drivers/nv50/nv50_vbo.c +1 -1
index f81929f..cbd9d6a 100644
@@ -139,7 +139,7 @@ nv50_draw_elements_inline_u16(struct nv50_context *nv50, uint16_t *map,
 }
 
 static INLINE void
-nv50_draw_elements_inline_u32(struct nv50_context *nv50, uint8_t *map,
+nv50_draw_elements_inline_u32(struct nv50_context *nv50, uint32_t *map,
 			      unsigned start, unsigned count)
 {
 	struct nouveau_channel *chan = nv50->screen->tesla->channel;
Signature · 1 line
1.6.3.3

From 7ca453090979a133bc81be682d6b006947ef756d Mon Sep 17 00:00:00 2001
From: Christoph Bumiller <e0425955-oe7qfRrRQffzPE21tAIdciO7C/[email protected]>
Date: Tue, 28 Jul 2009 17:34:07 +0200
Subject: [PATCH 6/8] nv50: support more vtxelt formats

NOTE: we must not try to emit buffer relocations when vtxbuf_nr is 0 but vtxelt_nr is not

---
 src/gallium/drivers/nv50/nv50_vbo.c |   80 ++++++++++++++++++++++++----------
 1 files changed, 56 insertions(+), 24 deletions(-)
src/gallium/drivers/nv50/nv50_vbo.c +56 -24

98 lines not on this page · raw message

Signature · 1 line
1.6.3.3

From 80706efc3d71865fc9a3a3acda0a7e2f34ea32ab Mon Sep 17 00:00:00 2001
From: Christoph Bumiller <e0425955-oe7qfRrRQffzPE21tAIdciO7C/[email protected]>
Date: Tue, 28 Jul 2009 17:38:28 +0200
Subject: [PATCH 7/8] nv50: use new 2D surface format names

---
 src/gallium/drivers/nv50/nv50_surface.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
src/gallium/drivers/nv50/nv50_surface.c +4 -4
index 3da9d6e..31c36a1 100644
@@ -35,13 +35,13 @@ nv50_format(enum pipe_format format)
 {
 	switch (format) {
 	case PIPE_FORMAT_A8R8G8B8_UNORM:
-		return NV50_2D_DST_FORMAT_32BPP;
+		return NV50_2D_DST_FORMAT_A8R8G8B8_UNORM;
 	case PIPE_FORMAT_X8R8G8B8_UNORM:
-		return NV50_2D_DST_FORMAT_24BPP;
+		return NV50_2D_DST_FORMAT_X8R8G8B8_UNORM;
 	case PIPE_FORMAT_R5G6B5_UNORM:
-		return NV50_2D_DST_FORMAT_16BPP;
+		return NV50_2D_DST_FORMAT_R5G6B5_UNORM;
 	case PIPE_FORMAT_A8_UNORM:
-		return NV50_2D_DST_FORMAT_8BPP;
+		return NV50_2D_DST_FORMAT_R8_UNORM;
 	default:
 		return -1;
 	}
Signature · 1 line
1.6.3.3

From 92bd0d46fa55f0f2a154d150fbb69b3daf7bbd2c Mon Sep 17 00:00:00 2001
From: Christoph Bumiller <e0425955-oe7qfRrRQffzPE21tAIdciO7C/[email protected]>
Date: Wed, 29 Jul 2009 01:07:52 +0200
Subject: [PATCH 8/8] nv50: correct zeta formats

What was Z24S8 before is actually S8Z24, and what we had for Z16 is actually X8Z24. Now, we also have the REAL Z24S8 and I added Z32_FLOAT as well; most of the formats need different tile_flags.

---
 src/gallium/drivers/nv50/nv50_miptree.c        |    9 +++++++--
 src/gallium/drivers/nv50/nv50_screen.c         |    5 +++--
 src/gallium/drivers/nv50/nv50_state_validate.c |   15 ++++++++++-----
 3 files changed, 20 insertions(+), 9 deletions(-)
src/gallium/drivers/nv50/nv50_miptree.c +7 -2
index 22465e0..c839279 100644
@@ -42,9 +42,14 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
 	mt->base.screen = pscreen;
 
 	switch (pt->format) {
-	case PIPE_FORMAT_Z24X8_UNORM:
+	case PIPE_FORMAT_Z32_FLOAT:
+		tile_flags = 0x4800;
+		break;
 	case PIPE_FORMAT_Z24S8_UNORM:
-	case PIPE_FORMAT_Z16_UNORM:
+		tile_flags = 0x1800;
+		break;
+	case PIPE_FORMAT_X8Z24_UNORM:
+	case PIPE_FORMAT_S8Z24_UNORM:
 		tile_flags = 0x2800;
 		break;
 	default:
src/gallium/drivers/nv50/nv50_screen.c +3 -2
index 349619d..0f6b1ae 100644
@@ -44,9 +44,10 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen,
 	} else
 	if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) {
 		switch (format) {
+		case PIPE_FORMAT_Z32_FLOAT:
 		case PIPE_FORMAT_Z24S8_UNORM:
-		case PIPE_FORMAT_Z24X8_UNORM:
-		case PIPE_FORMAT_Z16_UNORM:
+		case PIPE_FORMAT_X8Z24_UNORM:
+		case PIPE_FORMAT_S8Z24_UNORM:
 			return TRUE;
 		default:
 			break;
src/gallium/drivers/nv50/nv50_state_validate.c +10 -5
index ce8e44f..4a49b10 100644
@@ -92,17 +92,22 @@ nv50_state_validate_fb(struct nv50_context *nv50)
 		so_reloc (so, bo, fb->zsbuf->offset, NOUVEAU_BO_VRAM |
 			      NOUVEAU_BO_LOW | NOUVEAU_BO_RDWR, 0, 0);
 		switch (fb->zsbuf->format) {
+		case PIPE_FORMAT_Z32_FLOAT:
+			so_data(so, NV50TCL_ZETA_FORMAT_Z32_FLOAT);
+			break;
 		case PIPE_FORMAT_Z24S8_UNORM:
-		case PIPE_FORMAT_Z24X8_UNORM:
-			so_data(so, 0x16);
+			so_data(so, NV50TCL_ZETA_FORMAT_Z24S8_UNORM);
+			break;
+		case PIPE_FORMAT_X8Z24_UNORM:
+			so_data(so, NV50TCL_ZETA_FORMAT_X8Z24_UNORM);
 			break;
-		case PIPE_FORMAT_Z16_UNORM:
-			so_data(so, 0x15);
+		case PIPE_FORMAT_S8Z24_UNORM:
+			so_data(so, NV50TCL_ZETA_FORMAT_S8Z24_UNORM);
 			break;
 		default:
 			NOUVEAU_ERR("AIIII unknown format %s\n",
 				    pf_name(fb->zsbuf->format));
-			so_data(so, 0x16);
+			so_data(so, NV50TCL_ZETA_FORMAT_S8Z24_UNORM);
 			break;
 		}
 		so_data(so, bo->tile_mode << 4);
Signature · 1 line
1.6.3.3

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