mesa: Branch 'master' - 5 commits

Stephane Marchesin marcheu at kemper.freedesktop.org
Sun Jan 14 22:58:47 UTC 2007


 src/mesa/drivers/dri/nouveau/Makefile              |    1 
 src/mesa/drivers/dri/nouveau/nouveau_fifo.h        |    3 
 src/mesa/drivers/dri/nouveau/nouveau_reg.h         |  231 +++++++-
 src/mesa/drivers/dri/nouveau/nouveau_state_cache.c |    5 
 src/mesa/drivers/dri/nouveau/nouveau_state_cache.h |    8 
 src/mesa/drivers/dri/nouveau/nouveau_swtcl.c       |    4 
 src/mesa/drivers/dri/nouveau/nv04_swtcl.c          |  570 +++++++++++++++++++++
 src/mesa/drivers/dri/nouveau/nv04_swtcl.h          |   12 
 src/mesa/drivers/dri/nouveau/nv10_swtcl.c          |   58 --
 src/mesa/drivers/dri/nouveau/nv30_state.c          |   66 ++
 10 files changed, 873 insertions(+), 85 deletions(-)

New commits:
diff-tree 89f91d1804c0c4919c25d6b9931973733db1e664 (from e2295511f5ee5fc4f5b39cba9e9c1c7a2f4e1eb5)
Author: Carlos Martín Nieto <carlos at cmartin.tk>
Date:   Mon Jan 15 00:00:30 2007 +0100

    nouveau: Implement much of the fog handling.

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_reg.h b/src/mesa/drivers/dri/nouveau/nouveau_reg.h
index f52d381..8758b53 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_reg.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_reg.h
@@ -1035,6 +1035,7 @@ Object NV30_TCL_PRIMITIVE_3D used on: NV
 #	define		NV30_TCL_PRIMITIVE_3D_STENCIL_FRONT_OP_ZPASS		0x00000364
 #	define		NV30_TCL_PRIMITIVE_3D_SHADE_MODEL			0x00000368
 #	define		NV30_TCL_PRIMITIVE_3D_FOG_ENABLE			0x0000036c
+#	define		NV30_TCL_PRIMITIVE_3D_FOG_COLOR				0x00000370
 #	define		NV40_TCL_PRIMITIVE_3D_COLOR_MASK_BUFFER123		0x00000370	/* Parameters: buffer3 b buffer3 g buffer3 r buffer3 a buffer2 b buffer2 g buffer2 r buffer2 a buffer1 b buffer1 g buffer1 r buffer1 a */
 #	define		NV30_TCL_PRIMITIVE_3D_NORMALIZE_ENABLE			0x0000037c
 #	define		NV30_TCL_PRIMITIVE_3D_DEPTH_RANGE_NEAR			0x00000394
diff --git a/src/mesa/drivers/dri/nouveau/nv30_state.c b/src/mesa/drivers/dri/nouveau/nv30_state.c
index 9bf5f2a..4d79bb6 100644
--- a/src/mesa/drivers/dri/nouveau/nv30_state.c
+++ b/src/mesa/drivers/dri/nouveau/nv30_state.c
@@ -348,17 +348,71 @@ static void nv30Enable(GLcontext *ctx, G
 static void nv30Fogfv(GLcontext *ctx, GLenum pname, const GLfloat *params)
 {
     nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+
+    if (NOUVEAU_CARD_USING_SHADERS)
+        return;
+
     switch(pname)
     {
-        case GL_FOG_MODE:
-            //BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_FOG_MODE, 1);
-            //OUT_RING_CACHE (params);
+    case GL_FOG_MODE:
+    {
+        int mode = 0;
+        /* The modes are different in GL and the card.  */
+        switch(ctx->Fog.Mode)
+        {
+        case GL_LINEAR:
+            mode = 0x804;
             break;
-            /* TODO: unsure about the rest.*/
-        default:
+        case GL_EXP:
+            mode = 0x802;
             break;
+        case GL_EXP2:
+            mode = 0x803;
+            break;
+        }
+	BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_FOG_MODE, 1);
+	OUT_RING_CACHE (mode);
+	break;
+    }
+    case GL_FOG_COLOR:
+    {
+	GLubyte c[4];
+	UNCLAMPED_FLOAT_TO_RGBA_CHAN(c,params);
+        BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_FOG_COLOR, 1);
+        /* nvidia ignores the alpha channel */
+	OUT_RING_CACHE(PACK_COLOR_8888_REV(c[0],c[1],c[2],c[3]));
+        break;
+    }
+    case GL_FOG_DENSITY:
+    case GL_FOG_START:
+    case GL_FOG_END:
+    {
+        GLfloat f=0., c=0.;
+        switch(ctx->Fog.Mode)
+        {
+        case GL_LINEAR:
+            f = -1.0/(ctx->Fog.End - ctx->Fog.Start);
+            c = ctx->Fog.Start/(ctx->Fog.End - ctx->Fog.Start) + 2.001953;
+            break;
+        case GL_EXP:
+            f = -0.090168*ctx->Fog.Density;
+            c = 1.5;
+        case GL_EXP2:
+            f = -0.212330*ctx->Fog.Density;
+            c = 1.5;
+        }
+        BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_FOG_EQUATION_LINEAR, 1);
+        OUT_RING_CACHE(f);
+        BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_FOG_EQUATION_CONSTANT, 1);
+        OUT_RING_CACHE(c);
+        BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_FOG_EQUATION_QUADRATIC, 1);
+        OUT_RING_CACHE(0); /* Is this always the same? */
+        break;
+    }
+//    case GL_FOG_COORD_SRC:
+    default:
+        break;
     }
-
 }
    
 static void nv30Hint(GLcontext *ctx, GLenum target, GLenum mode)
diff-tree e2295511f5ee5fc4f5b39cba9e9c1c7a2f4e1eb5 (from 65e3d5e45e3d14f4ff98a15af0662e6c6e589cd2)
Author: Stephane Marchesin <marchesin at icps.u-strasbg.fr>
Date:   Sun Jan 14 22:39:37 2007 +0100

    nouveau: Update nouveau_reg.h from renouveau to the latest version.

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_reg.h b/src/mesa/drivers/dri/nouveau/nouveau_reg.h
index 74f55c6..f52d381 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_reg.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_reg.h
@@ -43,7 +43,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DE
 
 **************************************************************************
 
-   Created from objects.c rev. 1.350
+   Created from objects.c rev. 1.398
 */
 
 #ifndef _NOUVEAU_REG_H
@@ -60,6 +60,7 @@ Object NV01_CONTEXT_CLIP_RECTANGLE used 
 Object NV_MEMORY_TO_MEMORY_FORMAT used on: NV04 NV10 NV15 NV20 NV30 NV40 G70
 */
 #define			NV_MEMORY_TO_MEMORY_FORMAT				0x00000039
+#	define		NV_MEMORY_TO_MEMORY_FORMAT_NOP				0x00000100
 #	define		NV_MEMORY_TO_MEMORY_FORMAT_NOTIFY			0x00000104
 #	define		NV_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY			0x00000180
 #	define		NV_MEMORY_TO_MEMORY_FORMAT_OBJECT_IN			0x00000184
@@ -70,6 +71,8 @@ Object NV_MEMORY_TO_MEMORY_FORMAT used o
 #	define		NV_MEMORY_TO_MEMORY_FORMAT_PITCH_OUT			0x00000318
 #	define		NV_MEMORY_TO_MEMORY_FORMAT_LINE_LENGTH_IN		0x0000031c
 #	define		NV_MEMORY_TO_MEMORY_FORMAT_LINE_COUNT			0x00000320
+#	define		NV_MEMORY_TO_MEMORY_FORMAT_FORMAT			0x00000324	/* Parameters: src_inc dst_inc */
+#	define		NV_MEMORY_TO_MEMORY_FORMAT_BUF_NOTIFY			0x00000328
 
 /****************************************** 
 Object NV03_PRIMITIVE_RASTER_OP used on: NV03 NV04 NV10 NV15 NV20 NV30 NV40 G70
@@ -322,18 +325,19 @@ Object NV11_TCL_PRIMITIVE_3D used on: NV
 #	define		NV10_TCL_PRIMITIVE_3D_TX_NPOT_PITCH(d)			(0x00000230 + d * 0x0004)	/* Parameters: pitch */
 #	define		NV10_TCL_PRIMITIVE_3D_TX_NPOT_SIZE(d)			(0x00000240 + d * 0x0004)	/* Parameters: width height */
 #	define		NV10_TCL_PRIMITIVE_3D_TX_FILTER(d)			(0x00000248 + d * 0x0004)	/* Parameters: mag_filter min_filter */
+#	define		NV10_TCL_PRIMITIVE_3D_TX_PALETTE_OFFSET(d)		(0x00000250 + d * 0x0004)
+#	define		NV10_TCL_PRIMITIVE_3D_TX_MATRIX_ENABLE(d)		(0x000003e0 + d * 0x0004)
+#	define		NV10_TCL_PRIMITIVE_3D_TX_MATRIX(x,y)			(0x00000540 + y * 0x0010 + x * 0x0004)
 #	define		NV10_TCL_PRIMITIVE_3D_RC_IN_ALPHA(d)			(0x00000260 + d * 0x0004)	/* Parameters: vara_mapping vara_component_usage vara_input varb_mapping varb_component_usage varb_input varc_mapping varc_component_usage varc_input vard_mapping vard_component_usage vard_input */
 #	define		NV10_TCL_PRIMITIVE_3D_RC_IN_RGB(d)			(0x00000268 + d * 0x0004)	/* Parameters: vara_mapping vara_component_usage vara_input varb_mapping varb_component_usage varb_input varc_mapping varc_component_usage varc_input vard_mapping vard_component_usage vard_input */
 #	define		NV10_TCL_PRIMITIVE_3D_RC_OUT_ALPHA(d)			(0x00000278 + d * 0x0004)	/* Parameters: scale bias mux_sum ab_dot_product cd_dot_product sum_output ab_output cd_output */
 #	define		NV10_TCL_PRIMITIVE_3D_RC_OUT_RGB(d)			(0x00000280 + d * 0x0004)	/* Parameters: rc1_tx_units_enabled rc1_rc_enabled scale bias mux_sum ab_dot_product cd_dot_product sum_output ab_output cd_output */
-#	define		NV10_TCL_PRIMITIVE_3D_TX_MATRIX_ENABLE(d)		(0x000003e0 + d * 0x0004)
-#	define		NV10_TCL_PRIMITIVE_3D_TX_MATRIX(x,y)			(0x00000540 + y * 0x0010 + x * 0x0004)
 #	define		NV10_TCL_PRIMITIVE_3D_RC_COLOR0				0x00000270	/* Parameters: a r g b */
 #	define		NV10_TCL_PRIMITIVE_3D_RC_COLOR1				0x00000274	/* Parameters: a r g b */
 #	define		NV10_TCL_PRIMITIVE_3D_RC_FINAL0				0x00000288	/* Parameters: vara_mapping vara_component_usage vara_input varb_mapping varb_component_usage varb_input varc_mapping varc_component_usage varc_input vard_mapping vard_component_usage vard_input */
 #	define		NV10_TCL_PRIMITIVE_3D_RC_FINAL1				0x0000028c	/* Parameters: vare_mapping vare_component_usage vare_input varf_mapping varf_component_usage varf_input varg_mapping varg_component_usage varg_input color_sum_clamp */
 #	define		NV10_TCL_PRIMITIVE_3D_LIGHT_MODEL			0x00000294	/* Parameters: local_viewer color_control */
-#	define		NV10_TCL_PRIMITIVE_3D_COLOR_MATERIAL			0x00000298	/* Parameters: specular diffuse ambient emission */
+#	define		NV10_TCL_PRIMITIVE_3D_COLOR_MATERIAL_ENABLE		0x00000298	/* Parameters: specular diffuse ambient emission */
 #	define		NV10_TCL_PRIMITIVE_3D_FOG_MODE				0x0000029c
 #	define		NV10_TCL_PRIMITIVE_3D_FOG_COORD_DIST			0x000002a0
 #	define		NV10_TCL_PRIMITIVE_3D_FOG_ENABLE			0x000002a4
@@ -363,7 +367,7 @@ Object NV11_TCL_PRIMITIVE_3D used on: NV
 #	define		NV10_TCL_PRIMITIVE_3D_BLEND_COLOR			0x0000034c	/* Parameters: a r g b */
 #	define		NV10_TCL_PRIMITIVE_3D_BLEND_EQUATION			0x00000350
 #	define		NV10_TCL_PRIMITIVE_3D_DEPTH_FUNC			0x00000354
-#	define		NV10_TCL_PRIMITIVE_3D_COLOR_MASK			0x00000358	/* Parameters: r g b */
+#	define		NV10_TCL_PRIMITIVE_3D_COLOR_MASK			0x00000358	/* Parameters: a r g b */
 #	define		NV10_TCL_PRIMITIVE_3D_DEPTH_WRITE_ENABLE		0x0000035c
 #	define		NV10_TCL_PRIMITIVE_3D_STENCIL_MASK			0x00000360
 #	define		NV10_TCL_PRIMITIVE_3D_STENCIL_FUNC_FUNC			0x00000364
@@ -498,7 +502,7 @@ Object NV11_TCL_PRIMITIVE_3D used on: NV
 #	define		NV10_TCL_PRIMITIVE_3D_VERTEX_FOG_1F			0x00000ce0
 #	define		NV10_TCL_PRIMITIVE_3D_VERTEX_WGH_1F			0x00000ce4
 #	define		NV10_TCL_PRIMITIVE_3D_EDGEFLAG_ENABLE			0x00000cec
-#	define		NV10_TCL_PRIMITIVE_3D_VERTEX_ATTR( d)			(0x00000d04 + d * 0x0008)
+#	define		NV10_TCL_PRIMITIVE_3D_VERTEX_ATTR( d)			(0x00000d04 + d * 0x0008)	/* Parameters: stride fields type */
 #	define		NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_VALIDATE		0x00000cf0
 #	define		NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_OFFSET_POS		0x00000d00
 #	define		NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_FORMAT_POS		0x00000d04	/* Parameters: stride fields type */
@@ -595,6 +599,7 @@ Object NV10_UNK0072 used on: NV10 NV15 N
 */
 #define			NV10_UNK0072						0x00000072
 #	define		NV10_UNK0072_COUNTER					0x00000050
+#	define		NV40_UNK0072_SET_OBJECT					0x00000060
 #	define		NV10_UNK0072_SET_DMA_NOTIFY				0x00000180
 
 /****************************************** 
@@ -667,6 +672,8 @@ Object NV20_SWIZZLED_SURFACE used on: NV
 Object NV20_TCL_PRIMITIVE_3D used on: NV20 
 */
 #define			NV20_TCL_PRIMITIVE_3D					0x00000097
+#	define		NV20_TCL_PRIMITIVE_3D_NOP				0x00000100
+#	define		NV20_TCL_PRIMITIVE_3D_NOTIFY				0x00000104
 #	define		NV20_TCL_PRIMITIVE_3D_SET_OBJECT0			0x00000180
 #	define		NV20_TCL_PRIMITIVE_3D_SET_OBJECT1			0x00000184
 #	define		NV20_TCL_PRIMITIVE_3D_SET_OBJECT2			0x00000188
@@ -691,6 +698,8 @@ Object NV20_TCL_PRIMITIVE_3D used on: NV
 #	define		NV20_TCL_PRIMITIVE_3D_FOG_MODE				0x0000029c
 #	define		NV20_TCL_PRIMITIVE_3D_FOG_COORD_DIST			0x000002a0
 #	define		NV20_TCL_PRIMITIVE_3D_FOG_ENABLE			0x000002a4
+#	define		NV20_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(d)		(0x000002c0 + d * 0x0004)	/* Parameters: x2 x1 */
+#	define		NV20_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_VERT(d)		(0x000002e0 + d * 0x0004)	/* Parameters: y2 y1 */
 #	define		NV20_TCL_PRIMITIVE_3D_ALPHA_FUNC_ENABLE			0x00000300
 #	define		NV20_TCL_PRIMITIVE_3D_BLEND_FUNC_ENABLE			0x00000304
 #	define		NV20_TCL_PRIMITIVE_3D_CULL_FACE_ENABLE			0x00000308
@@ -759,6 +768,10 @@ Object NV20_TCL_PRIMITIVE_3D used on: NV
 #	define		NV20_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_E	0x000009f0
 #	define		NV20_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_F	0x000009f4
 #	define		NV20_TCL_PRIMITIVE_3D_POINT_SPRITE			0x00000a1c	/* Parameters: coord_replace r_mode enable */
+#	define		NV20_TCL_PRIMITIVE_3D_VIEWPORT_OX			0x00000a20
+#	define		NV20_TCL_PRIMITIVE_3D_VIEWPORT_OY			0x00000a24
+#	define		NV20_TCL_PRIMITIVE_3D_VIEWPORT_DEPTH_AVG_S		0x00000a28
+#	define		NV20_TCL_PRIMITIVE_3D_VIEWPORT_UNKNOWN_A		0x00000a2c
 #	define		NV20_TCL_PRIMITIVE_3D_POINT_PARAMETER_A			0x00000a30
 #	define		NV20_TCL_PRIMITIVE_3D_POINT_PARAMETER_B			0x00000a34
 #	define		NV20_TCL_PRIMITIVE_3D_POINT_PARAMETER_C			0x00000a38
@@ -767,6 +780,10 @@ Object NV20_TCL_PRIMITIVE_3D used on: NV
 #	define		NV20_TCL_PRIMITIVE_3D_POINT_PARAMETER_F			0x00000a44
 #	define		NV20_TCL_PRIMITIVE_3D_POINT_PARAMETER_G			0x00000a48
 #	define		NV20_TCL_PRIMITIVE_3D_POINT_PARAMETER_H			0x00000a4c
+#	define		NV20_TCL_PRIMITIVE_3D_VIEWPORT_PX_DIV2			0x00000af0
+#	define		NV20_TCL_PRIMITIVE_3D_VIEWPORT_PY_DIV2			0x00000af4
+#	define		NV20_TCL_PRIMITIVE_3D_VIEWPORT_DEPTH_HALF_S		0x00000af8
+#	define		NV20_TCL_PRIMITIVE_3D_VIEWPORT_UNKNOWN_B		0x00000afc
 #	define		NV20_TCL_PRIMITIVE_3D_VP_UPLOAD_INST0			0x00000b00
 #	define		NV20_TCL_PRIMITIVE_3D_VP_UPLOAD_INST1			0x00000b04
 #	define		NV20_TCL_PRIMITIVE_3D_VP_UPLOAD_INST2			0x00000b08
@@ -781,10 +798,13 @@ Object NV20_TCL_PRIMITIVE_3D used on: NV
 #	define		NV20_TCL_PRIMITIVE_3D_LIGHT_MODEL_FRONT_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_B	0x00000a18
 #	define		NV20_TCL_PRIMITIVE_3D_TX_OFFSET(d)			(0x00001b00 + d * 0x0040)
 #	define		NV20_TCL_PRIMITIVE_3D_TX_FORMAT(d)			(0x00001b04 + d * 0x0040)	/* Parameters: log2(height) log2(width) lod format cube_map */
+#	define		NV20_TCL_PRIMITIVE_3D_TX_WRAP(d)			(0x00001b08 + d * 0x0040)	/* Parameters: wrap_s wrap_t wrap_r */
 #	define		NV20_TCL_PRIMITIVE_3D_TX_ENABLE(d)			(0x00001b0c + d * 0x0040)	/* Parameters: enable anisotropy */
 #	define		NV20_TCL_PRIMITIVE_3D_TX_NPOT_PITCH(d)			(0x00001b10 + d * 0x0040)	/* Parameters: pitch */
 #	define		NV20_TCL_PRIMITIVE_3D_TX_FILTER(d)			(0x00001b14 + d * 0x0040)	/* Parameters: mag_filter min_filter */
 #	define		NV20_TCL_PRIMITIVE_3D_TX_NPOT_SIZE(d)			(0x00001b1c + d * 0x0040)	/* Parameters: width height */
+#	define		NV20_TCL_PRIMITIVE_3D_TX_PALETTE_OFFSET(d)		(0x00001b20 + d * 0x0040)
+#	define		NV20_TCL_PRIMITIVE_3D_RC_ENABLE				0x00001e60	/* Parameters: number of rc enabled */
 #	define		NV20_TCL_PRIMITIVE_3D_TX_SHADER_OP			0x00001e70	/* Parameters: op0 op1 op2 op3 */
 #	define		NV20_TCL_PRIMITIVE_3D_TX_SHADER_CULL_MODE		0x000017f8	/* Parameters: cull0 cull1 cull2 cull3 */
 #	define		NV20_TCL_PRIMITIVE_3D_TX_SHADER_PREVIOUS		0x00001e78	/* Parameters: prev2 prev3 */
@@ -794,6 +814,8 @@ Object NV20_TCL_PRIMITIVE_3D used on: NV
 #	define		NV20_TCL_PRIMITIVE_3D_RC_FINAL1				0x0000028c	/* Parameters: vare_mapping vare_component_usage vare_input varf_mapping varf_component_usage varf_input varg_mapping varg_component_usage varg_input color_sum_clamp */
 #	define		NV20_TCL_PRIMITIVE_3D_RC_IN_ALPHA(d)			(0x00000260 + d * 0x0004)	/* Parameters: vara_mapping vara_component_usage vara_input varb_mapping varb_component_usage varb_input varc_mapping varc_component_usage varc_input vard_mapping vard_component_usage vard_input */
 #	define		NV20_TCL_PRIMITIVE_3D_RC_IN_RGB(d)			(0x00000ac0 + d * 0x0004)	/* Parameters: vara_mapping vara_component_usage vara_input varb_mapping varb_component_usage varb_input varc_mapping varc_component_usage varc_input vard_mapping vard_component_usage vard_input */
+#	define		NV20_TCL_PRIMITIVE_3D_RC_CONSTANT_COLOR0(d)		(0x00000a60 + d * 0x0004)	/* Parameters: a r g b */
+#	define		NV20_TCL_PRIMITIVE_3D_RC_CONSTANT_COLOR1(d)		(0x00000a80 + d * 0x0004)	/* Parameters: a r g b */
 #	define		NV20_TCL_PRIMITIVE_3D_RC_OUT_ALPHA(d)			(0x00000aa0 + d * 0x0004)	/* Parameters: scale bias mux_sum ab_dot_product cd_dot_product sum_output ab_output cd_output */
 #	define		NV20_TCL_PRIMITIVE_3D_RC_OUT_RGB(d)			(0x00001e40 + d * 0x0004)	/* Parameters: scale bias mux_sum ab_dot_product cd_dot_product sum_output ab_output cd_output */
 #	define		NV20_TCL_PRIMITIVE_3D_LIGHT_POSITION_X(d)		(0x0000105c + d * 0x0080)
@@ -943,12 +965,18 @@ Object NV20_TCL_PRIMITIVE_3D used on: NV
 #	define		NV20_TCL_PRIMITIVE_3D_COLOR_LOGIC_OP_OP			0x000017c0
 #	define		NV20_TCL_PRIMITIVE_3D_LIGHT_MODEL_TWO_SIDE_ENABLE	0x000017c4
 #	define		NV20_TCL_PRIMITIVE_3D_BEGIN_END				0x000017fc
+#	define		NV20_TCL_PRIMITIVE_3D_SCISSOR_X2_X1			0x00001c30	/* Parameters: x2 x1 */
+#	define		NV20_TCL_PRIMITIVE_3D_SCISSOR_Y2_Y1			0x00001c50	/* Parameters: y2 y1 */
 #	define		NV20_TCL_PRIMITIVE_3D_CLEAR_VALUE_DEPTH			0x00001d8c
 #	define		NV20_TCL_PRIMITIVE_3D_CLEAR_VALUE_ARGB			0x00001d90
 #	define		NV20_TCL_PRIMITIVE_3D_CLEAR_WHICH_BUFFERS		0x00001d94	/* Parameters: clear color a clear color b clear color g clear color r clear depth clear stencil */
 #	define		NV20_TCL_PRIMITIVE_3D_INDEX_DATA			0x00001800	/* Parameters: index1 index0 */
 #	define		NV20_TCL_PRIMITIVE_3D_VB_VERTEX_BATCH			0x00001810	/* Parameters: count_vertices offset_vertices */
 #	define		NV20_TCL_PRIMITIVE_3D_VERTEX_DATA			0x00001818
+#	define		NV20_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X			0x00001f00
+#	define		NV20_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_Y			0x00001f04
+#	define		NV20_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_Z			0x00001f08
+#	define		NV20_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_W			0x00001f0c
 
 /****************************************** 
 Object NV30_TCL_PRIMITIVE_3D used on: NV30 NV40 G70
@@ -965,8 +993,8 @@ Object NV30_TCL_PRIMITIVE_3D used on: NV
 #	define		NV30_TCL_PRIMITIVE_3D_SET_OBJECT8			0x000001ac
 #	define		NV30_TCL_PRIMITIVE_3D_SET_OBJECT9			0x000001b4
 #	define		NV30_TCL_PRIMITIVE_3D_SET_OBJECT10			0x000001b8
-#	define		NV30_TCL_PRIMITIVE_3D_SET_OBJECT11			0x0000019c
-#	define		NV30_TCL_PRIMITIVE_3D_SET_OBJECT12			0x000001a0
+#	define		NV30_TCL_PRIMITIVE_3D_SET_VB_SRC0_OBJECT		0x0000019c
+#	define		NV30_TCL_PRIMITIVE_3D_SET_VB_SRC1_OBJECT		0x000001a0
 #	define		NV30_TCL_PRIMITIVE_3D_BUFFER0_PITCH			0x0000020c	/* Parameters: depth/stencil buffer pitch color0 buffer pitch */
 #	define		NV30_TCL_PRIMITIVE_3D_COLOR0_OFFSET			0x00000210
 #	define		NV30_TCL_PRIMITIVE_3D_DEPTH_OFFSET			0x00000214
@@ -1016,6 +1044,7 @@ Object NV30_TCL_PRIMITIVE_3D used on: NV
 #	define		NV30_TCL_PRIMITIVE_3D_COLOR_MATERIAL_FRONT_B		0x000003a8
 #	define		NV30_TCL_PRIMITIVE_3D_COLOR_MATERIAL_FRONT_A		0x000003b4
 #	define		NV30_TCL_PRIMITIVE_3D_LINE_WIDTH_SMOOTH			0x000003b8
+#	define		NV30_TCL_PRIMITIVE_3D_LINE_SMOOTH_ENABLE		0x000003bc
 #	define		NV30_TCL_PRIMITIVE_3D_CLIP_PLANE_ENABLE(d)		(0x00000400 + d * 0x0004)
 #	define		NV30_TCL_PRIMITIVE_3D_MODELVIEW_MATRIX( d)		(0x00000480 + d * 0x0004)
 #	define		NV30_TCL_PRIMITIVE_3D_INVERSE_MODELVIEW_MATRIX( d)	(0x00000580 + d * 0x0004)
@@ -1027,12 +1056,17 @@ Object NV30_TCL_PRIMITIVE_3D used on: NV
 #	define		NV30_TCL_PRIMITIVE_3D_FOG_EQUATION_CONSTANT		0x000008d0
 #	define		NV30_TCL_PRIMITIVE_3D_FOG_EQUATION_LINEAR		0x000008d4
 #	define		NV30_TCL_PRIMITIVE_3D_FOG_EQUATION_QUADRATIC		0x000008d8
+#	define		NV30_TCL_PRIMITIVE_3D_RC_COLOR0				0x000008ec	/* Parameters: a r g b */
+#	define		NV30_TCL_PRIMITIVE_3D_RC_COLOR1				0x000008f0	/* Parameters: a r g b */
 #	define		NV30_TCL_PRIMITIVE_3D_RC_FINAL0				0x000008f4	/* Parameters: vara_mapping vara_component_usage vara_input varb_mapping varb_component_usage varb_input varc_mapping varc_component_usage varc_input vard_mapping vard_component_usage vard_input */
 #	define		NV30_TCL_PRIMITIVE_3D_RC_FINAL1				0x000008f8	/* Parameters: vare_mapping vare_component_usage vare_input varf_mapping varf_component_usage varf_input varg_mapping varg_component_usage varg_input color_sum_clamp */
-#	define		NV30_TCL_PRIMITIVE_3D_RC_IN_ALPHA			0x00000900	/* Parameters: vara_mapping vara_component_usage vara_input varb_mapping varb_component_usage varb_input varc_mapping varc_component_usage varc_input vard_mapping vard_component_usage vard_input */
-#	define		NV30_TCL_PRIMITIVE_3D_RC_IN_RGB				0x00000904	/* Parameters: vara_mapping vara_component_usage vara_input varb_mapping varb_component_usage varb_input varc_mapping varc_component_usage varc_input vard_mapping vard_component_usage vard_input */
-#	define		NV30_TCL_PRIMITIVE_3D_RC_OUT_ALPHA			0x00000910	/* Parameters: scale bias mux_sum ab_dot_product cd_dot_product sum_output ab_output cd_output */
-#	define		NV30_TCL_PRIMITIVE_3D_RC_OUT_RGB			0x00000914	/* Parameters: scale bias mux_sum ab_dot_product cd_dot_product sum_output ab_output cd_output */
+#	define		NV30_TCL_PRIMITIVE_3D_RC_ENABLE				0x000008fc	/* Parameters: number of rc enabled */
+#	define		NV30_TCL_PRIMITIVE_3D_RC_IN_ALPHA(d)			(0x00000900 + d * 0x0020)	/* Parameters: vara_mapping vara_component_usage vara_input varb_mapping varb_component_usage varb_input varc_mapping varc_component_usage varc_input vard_mapping vard_component_usage vard_input */
+#	define		NV30_TCL_PRIMITIVE_3D_RC_IN_RGB(d)			(0x00000904 + d * 0x0020)	/* Parameters: vara_mapping vara_component_usage vara_input varb_mapping varb_component_usage varb_input varc_mapping varc_component_usage varc_input vard_mapping vard_component_usage vard_input */
+#	define		NV30_TCL_PRIMITIVE_3D_RC_CONSTANT_COLOR0(d)		(0x00000908 + d * 0x0020)	/* Parameters: a r g b */
+#	define		NV30_TCL_PRIMITIVE_3D_RC_CONSTANT_COLOR1(d)		(0x0000090c + d * 0x0020)	/* Parameters: a r g b */
+#	define		NV30_TCL_PRIMITIVE_3D_RC_OUT_ALPHA(d)			(0x00000910 + d * 0x0020)	/* Parameters: scale bias mux_sum ab_dot_product cd_dot_product sum_output ab_output cd_output */
+#	define		NV30_TCL_PRIMITIVE_3D_RC_OUT_RGB(d)			(0x00000914 + d * 0x0020)	/* Parameters: scale bias mux_sum ab_dot_product cd_dot_product sum_output ab_output cd_output */
 #	define		NV30_TCL_PRIMITIVE_3D_VIEWPORT_COLOR_BUFFER_DIM0	0x00000200	/* Parameters: width x_offset */
 #	define		NV30_TCL_PRIMITIVE_3D_VIEWPORT_COLOR_BUFFER_DIM1	0x00000204	/* Parameters: height y_offset */
 #	define		NV30_TCL_PRIMITIVE_3D_VIEWPORT_COLOR_BUFFER_OFS0	0x000002c0	/* Parameters: width x_offset */
@@ -1054,6 +1088,7 @@ Object NV30_TCL_PRIMITIVE_3D used on: NV
 #	define		NV30_TCL_PRIMITIVE_3D_POINT_PARAMETER_F			0x00001ed4
 #	define		NV30_TCL_PRIMITIVE_3D_POINT_PARAMETER_G			0x00001ed8
 #	define		NV30_TCL_PRIMITIVE_3D_POINT_PARAMETER_H			0x00001edc
+#	define		NV30_TCL_PRIMITIVE_3D_POINT_PARAMETERS_ENABLE		0x00001ee4
 #	define		NV30_TCL_PRIMITIVE_3D_VIEWPORT_XFRM_OX			0x00000a20
 #	define		NV30_TCL_PRIMITIVE_3D_VIEWPORT_XFRM_OY			0x00000a24
 #	define		NV30_TCL_PRIMITIVE_3D_VIEWPORT_XFRM_NPF_DIV2		0x00000a28
@@ -1074,6 +1109,10 @@ Object NV30_TCL_PRIMITIVE_3D used on: NV
 #	define		NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_INST1			0x00000b84
 #	define		NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_INST2			0x00000b88
 #	define		NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_INST3			0x00000b8c
+#	define		NV30_TCL_PRIMITIVE_3D_COLOR_MATERIAL_BACK_R		0x000017b0
+#	define		NV30_TCL_PRIMITIVE_3D_COLOR_MATERIAL_BACK_G		0x000017b4
+#	define		NV30_TCL_PRIMITIVE_3D_COLOR_MATERIAL_BACK_B		0x000017b8
+#	define		NV30_TCL_PRIMITIVE_3D_COLOR_MATERIAL_BACK_A		0x000017c0
 #	define		NV30_TCL_PRIMITIVE_3D_OCC_QUERY_OR_COLOR_BUFF_ENABLE	0x000017c8
 #	define		NV30_TCL_PRIMITIVE_3D_STORE_RESULT			0x00001800
 #	define		NV30_TCL_PRIMITIVE_3D_CLIP_PLANE_A(d)			(0x00000e00 + d * 0x0010)
@@ -1115,7 +1154,9 @@ Object NV30_TCL_PRIMITIVE_3D used on: NV
 #	define		NV30_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_E	0x00001410
 #	define		NV30_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_F	0x00001414
 #	define		NV30_TCL_PRIMITIVE_3D_ENABLED_LIGHTS			0x00001420	/* Parameters: light 7 light 6 light 5 light 4 light 3 light 2 light 1 light 0 */
-#	define		NV30_TCL_PRIMITIVE_3D_LINE_STIPPLE			0x00001db4
+#	define		NV30_TCL_PRIMITIVE_3D_UNK1D6C_OFFSET			0x00001d6c
+#	define		NV30_TCL_PRIMITIVE_3D_UNK1D70_VALUE			0x00001d70
+#	define		NV30_TCL_PRIMITIVE_3D_LINE_STIPPLE_ENABLE		0x00001db4
 #	define		NV30_TCL_PRIMITIVE_3D_LINE_STIPPLE_PATTERN		0x00001db8	/* Parameters: factor pattern */
 #	define		NV30_TCL_PRIMITIVE_3D_BEGIN_END				0x00001808
 #	define		NV30_TCL_PRIMITIVE_3D_CULL_FACE				0x00001830
@@ -1159,7 +1200,7 @@ Object NV30_TCL_PRIMITIVE_3D used on: NV
 #	define		NV30_TCL_PRIMITIVE_3D_VTX_ATTR_4Y(d)			(0x00001c04 + d * 0x0010)
 #	define		NV30_TCL_PRIMITIVE_3D_VTX_ATTR_4Z(d)			(0x00001c08 + d * 0x0010)
 #	define		NV30_TCL_PRIMITIVE_3D_VTX_ATTR_4W(d)			(0x00001c0c + d * 0x0010)
-#	define		NV30_TCL_PRIMITIVE_3D_VB_POINTER_ATTR(d)		(0x00001680 + d * 0x0004)	/* Parameters: enabled? offset */
+#	define		NV30_TCL_PRIMITIVE_3D_VB_POINTER_ATTR(d)		(0x00001680 + d * 0x0004)	/* Parameters: source: offset */
 #	define		NV30_TCL_PRIMITIVE_3D_VERTEX_NOR_3I_XY			0x00000a90	/* Parameters: y x */
 #	define		NV30_TCL_PRIMITIVE_3D_VERTEX_NOR_3I_Z			0x00000a94	/* Parameters: z */
 #	define		NV30_TCL_PRIMITIVE_3D_VERTEX_TX0_2F_S			0x000018c0
@@ -1206,10 +1247,6 @@ Object NV30_TCL_PRIMITIVE_3D used on: NV
 #	define		NV30_TCL_PRIMITIVE_3D_LIGHT_MODEL_BACK_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_R	0x000017a0
 #	define		NV30_TCL_PRIMITIVE_3D_LIGHT_MODEL_BACK_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_G	0x000017a4
 #	define		NV30_TCL_PRIMITIVE_3D_LIGHT_MODEL_BACK_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_B	0x000017a8
-#	define		NV30_TCL_PRIMITIVE_3D_COLOR_MATERIAL_BACK_R		0x000017b0
-#	define		NV30_TCL_PRIMITIVE_3D_COLOR_MATERIAL_BACK_G		0x000017b4
-#	define		NV30_TCL_PRIMITIVE_3D_COLOR_MATERIAL_BACK_B		0x000017b8
-#	define		NV30_TCL_PRIMITIVE_3D_COLOR_MATERIAL_BACK_A		0x000017c0
 #	define		NV30_TCL_PRIMITIVE_3D_FP_ACTIVE_PROGRAM			0x000008e4
 #	define		NV30_TCL_PRIMITIVE_3D_TX_ADDRESS_UNIT(d)		(0x00001a00 + d * 0x0020)
 #	define		NV30_TCL_PRIMITIVE_3D_TX_FORMAT_UNIT(d)			(0x00001a04 + d * 0x0020)	/* Parameters: mipmap type format ncomp cubic */
@@ -1221,6 +1258,8 @@ Object NV30_TCL_PRIMITIVE_3D used on: NV
 #	define		NV30_TCL_PRIMITIVE_3D_TX_UNK07_UNIT(d)			(0x00001a1c + d * 0x0020)
 #	define		NV30_TCL_PRIMITIVE_3D_TX_DEPTH_UNIT(d)			(0x00001840 + d * 0x0004)	/* Parameters: depth NPOT pitch */
 #	define		NV30_TCL_PRIMITIVE_3D_VB_VERTEX_BATCH			0x00001814	/* Parameters: count_vertices offset_vertices */
+#	define		NV30_TCL_PRIMITIVE_3D_VB_ELEMENT_U16			0x0000180c	/* Parameters: 1: 0: */
+#	define		NV30_TCL_PRIMITIVE_3D_VB_ELEMENT_U32			0x00001810
 #	define		NV30_TCL_PRIMITIVE_3D_VERTEX_DATA			0x00001818
 #	define		NV30_TCL_PRIMITIVE_3D_COLOR_LOGIC_OP_ENABLE		0x00000374
 #	define		NV30_TCL_PRIMITIVE_3D_COLOR_LOGIC_OP_OP			0x00000378
@@ -1245,6 +1284,161 @@ Object NV30_CLEAR_BUFFER used on: NV30 N
 #	define		NV30_CLEAR_BUFFER_UNK002fc				0x000002fc
 
 /****************************************** 
+Object NV50_TCL_PRIMITIVE_3D used on: 
+*/
+#define			NV50_TCL_PRIMITIVE_3D					0x00000097
+#	define		NV50_TCL_PRIMITIVE_3D_SET_OBJECT_0( d)			(0x00000180 + d * 0x0004)
+#	define		NV50_TCL_PRIMITIVE_3D_SET_OBJECT_1( d)			(0x000001c0 + d * 0x0004)
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_FOG_1F			0x00000314
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_POS_2F_X			0x00000380
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_POS_2F_Y			0x00000384
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX0_2F_S			0x000003c0
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX0_2F_T			0x000003c4
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX1_2F_S			0x000003c8
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX1_2F_T			0x000003cc
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX2_2F_S			0x000003d0
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX2_2F_T			0x000003d4
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX3_2F_S			0x000003d8
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX3_2F_T			0x000003dc
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_POS_3F_X			0x00000400
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_POS_3F_Y			0x00000404
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_POS_3F_Z			0x00000408
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_NOR_3F_X			0x00000420
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_NOR_3F_Y			0x00000424
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_NOR_3F_Z			0x00000428
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_COL_3F_R			0x00000430
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_COL_3F_G			0x00000434
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_COL_3F_B			0x00000438
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_COL2_3F_R			0x00000440
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_COL2_3F_G			0x00000444
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_COL2_3F_B			0x00000448
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_POS_4F_X			0x00000500
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_POS_4F_Y			0x00000504
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_POS_4F_Z			0x00000508
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_POS_4F_W			0x0000050c
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_COL_4F_R			0x00000530
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_COL_4F_G			0x00000534
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_COL_4F_B			0x00000538
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_COL_4F_A			0x0000053c
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX0_4F_S			0x00000580
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX0_4F_T			0x00000584
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX0_4F_R			0x00000588
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX0_4F_Q			0x0000058c
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX1_4F_S			0x00000590
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX1_4F_T			0x00000594
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX1_4F_R			0x00000598
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX1_4F_Q			0x0000059c
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX2_4F_S			0x000005a0
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX2_4F_T			0x000005a4
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX2_4F_R			0x000005a8
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX2_4F_Q			0x000005ac
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX3_4F_S			0x000005b0
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX3_4F_T			0x000005b4
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX3_4F_R			0x000005b8
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX3_4F_Q			0x000005bc
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX0_2I			0x000006a0	/* Parameters: t s */
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX1_2I			0x000006a4	/* Parameters: t s */
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX2_2I			0x000006a8	/* Parameters: t s */
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX3_2I			0x000006ac	/* Parameters: t s */
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_POS_4I_XY			0x00000700	/* Parameters: y x */
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_POS_4I_ZW			0x00000704	/* Parameters: w z */
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX0_4I_ST			0x00000740	/* Parameters: t s */
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX0_4I_RQ			0x00000744	/* Parameters: q r */
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX1_4I_ST			0x00000748	/* Parameters: t s */
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX1_4I_RQ			0x0000074c	/* Parameters: q r */
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX2_4I_ST			0x00000750	/* Parameters: t s */
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX2_4I_RQ			0x00000754	/* Parameters: q r */
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX3_4I_ST			0x00000758	/* Parameters: t s */
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_TX3_4I_RQ			0x0000075c	/* Parameters: q r */
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_NOR_3I_XY			0x00000790	/* Parameters: y x */
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_NOR_3I_Z			0x00000794	/* Parameters: z */
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_COL_4I			0x0000088c	/* Parameters: a b g r */
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_COL2_3I			0x00000890	/* Parameters: a b g r */
+#	define		NV50_TCL_PRIMITIVE_3D_VIEWPORT_UNK0_X			0x00000a00
+#	define		NV50_TCL_PRIMITIVE_3D_VIEWPORT_UNK0_Y			0x00000a04
+#	define		NV50_TCL_PRIMITIVE_3D_VIEWPORT_UNK0_Z			0x00000a08
+#	define		NV50_TCL_PRIMITIVE_3D_VIEWPORT_UNK1_X			0x00000a0c
+#	define		NV50_TCL_PRIMITIVE_3D_VIEWPORT_UNK1_Y			0x00000a10
+#	define		NV50_TCL_PRIMITIVE_3D_VIEWPORT_UNK1_Z			0x00000a14
+#	define		NV50_TCL_PRIMITIVE_3D_DEPTH_RANGE_NEAR			0x00000c08
+#	define		NV50_TCL_PRIMITIVE_3D_DEPTH_RANGE_FAR			0x00000c0c
+#	define		NV50_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(d)		(0x00000d00 + d * 0x0008)	/* Parameters: x2 x1 */
+#	define		NV50_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_VERT(d)		(0x00000d04 + d * 0x0008)	/* Parameters: y2 y1 */
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_BUFFER_FIRST		0x00000d74
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_BUFFER_COUNT		0x00000d78
+#	define		NV50_TCL_PRIMITIVE_3D_CLEAR_COLOR_R			0x00000d80
+#	define		NV50_TCL_PRIMITIVE_3D_CLEAR_COLOR_G			0x00000d84
+#	define		NV50_TCL_PRIMITIVE_3D_CLEAR_COLOR_B			0x00000d88
+#	define		NV50_TCL_PRIMITIVE_3D_CLEAR_COLOR_A			0x00000d8c
+#	define		NV50_TCL_PRIMITIVE_3D_CLEAR_DEPTH			0x00000d90
+#	define		NV50_TCL_PRIMITIVE_3D_CLEAR_STENCIL			0x00000da0
+#	define		NV50_TCL_PRIMITIVE_3D_POLYGON_MODE_FRONT		0x00000dac
+#	define		NV50_TCL_PRIMITIVE_3D_POLYGON_MODE_BACK			0x00000db0
+#	define		NV50_TCL_PRIMITIVE_3D_POLYGON_SMOOTH_ENABLE		0x00000db4
+#	define		NV50_TCL_PRIMITIVE_3D_POLYGON_OFFSET_POINT_ENABLE	0x00000dc0
+#	define		NV50_TCL_PRIMITIVE_3D_POLYGON_OFFSET_LINE_ENABLE	0x00000dc4
+#	define		NV50_TCL_PRIMITIVE_3D_POLYGON_OFFSET_FILL_ENABLE	0x00000dc8
+#	define		NV50_TCL_PRIMITIVE_3D_SCISSOR_WIDTH_XPOS		0x00000e04	/* Parameters: w x */
+#	define		NV50_TCL_PRIMITIVE_3D_SCISSOR_HEIGHT_YPOS		0x00000e08	/* Parameters: h y */
+#	define		NV50_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_ID		0x00000f00
+#	define		NV50_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_X			0x00000f04
+#	define		NV50_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_Y			0x00000f08
+#	define		NV50_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_Z			0x00000f0c
+#	define		NV50_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_W			0x00000f10
+#	define		NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_FUNC_REF		0x00000f54
+#	define		NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_MASK		0x00000f58
+#	define		NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_FUNC_MASK		0x00000f5c
+#	define		NV50_TCL_PRIMITIVE_3D_DEPTH_TEST_ENABLE			0x000012cc
+#	define		NV50_TCL_PRIMITIVE_3D_SHADE_MODEL			0x000012d4
+#	define		NV50_TCL_PRIMITIVE_3D_DEPTH_WRITE_ENABLE		0x000012e8
+#	define		NV50_TCL_PRIMITIVE_3D_ALPHA_FUNC_ENABLE			0x000012ec
+#	define		NV50_TCL_PRIMITIVE_3D_DEPTH_FUNC			0x0000130c
+#	define		NV50_TCL_PRIMITIVE_3D_ALPHA_FUNC_REF			0x00001310
+#	define		NV50_TCL_PRIMITIVE_3D_ALPHA_FUNC_FUNC			0x00001314
+#	define		NV50_TCL_PRIMITIVE_3D_BLEND_COLOR_R			0x0000131c
+#	define		NV50_TCL_PRIMITIVE_3D_BLEND_COLOR_G			0x00001320
+#	define		NV50_TCL_PRIMITIVE_3D_BLEND_COLOR_B			0x00001324
+#	define		NV50_TCL_PRIMITIVE_3D_BLEND_COLOR_A			0x00001328
+#	define		NV50_TCL_PRIMITIVE_3D_BLEND_EQUATION_RGB		0x00001340
+#	define		NV50_TCL_PRIMITIVE_3D_BLEND_FUNC_SRC_RGB		0x00001344
+#	define		NV50_TCL_PRIMITIVE_3D_BLEND_FUNC_DST_RGB		0x00001348
+#	define		NV50_TCL_PRIMITIVE_3D_BLEND_EQUATION_ALPHA		0x0000134c
+#	define		NV50_TCL_PRIMITIVE_3D_BLEND_FUNC_SRC_ALPHA		0x00001350
+#	define		NV50_TCL_PRIMITIVE_3D_BLEND_FUNC_DST_ALPHA		0x00001358
+#	define		NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_ENABLE		0x00001380
+#	define		NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_OP_FAIL		0x00001384
+#	define		NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_OP_ZFAIL		0x00001388
+#	define		NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_OP_ZPASS		0x0000138c
+#	define		NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_FUNC_FUNC		0x00001390
+#	define		NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_FUNC_REF		0x00001394
+#	define		NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_MASK			0x00001398
+#	define		NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_FUNC_MASK		0x0000139c
+#	define		NV50_TCL_PRIMITIVE_3D_LINE_WIDTH			0x000013b0
+#	define		NV50_TCL_PRIMITIVE_3D_POINT_SIZE			0x00001518
+#	define		NV50_TCL_PRIMITIVE_3D_POLYGON_OFFSET_FACTOR		0x0000156c
+#	define		NV50_TCL_PRIMITIVE_3D_LINE_SMOOTH_ENABLE		0x00001570
+#	define		NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_ENABLE		0x00001594
+#	define		NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_OP_FAIL		0x00001598
+#	define		NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_OP_ZFAIL		0x0000159c
+#	define		NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_OP_ZPASS		0x000015a0
+#	define		NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_FUNC_FUNC		0x000015a4
+#	define		NV50_TCL_PRIMITIVE_3D_POLYGON_OFFSET_UNITS		0x000015bc
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_BEGIN			0x000015dc
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_END			0x000015e0
+#	define		NV50_TCL_PRIMITIVE_3D_VERTEX_DATA			0x00001640
+#	define		NV50_TCL_PRIMITIVE_3D_LINE_STIPPLE_ENABLE		0x0000166c
+#	define		NV50_TCL_PRIMITIVE_3D_LINE_STIPPLE_PATTERN		0x00001680	/* Parameters: pattern factor */
+#	define		NV50_TCL_PRIMITIVE_3D_POLYGON_STIPPLE_ENABLE		0x0000168c
+#	define		NV50_TCL_PRIMITIVE_3D_POLYGON_STIPPLE_PATTERN( d)	(0x00001700 + d * 0x0004)
+#	define		NV50_TCL_PRIMITIVE_3D_CULL_FACE_ENABLE			0x00001918
+#	define		NV50_TCL_PRIMITIVE_3D_FRONT_FACE			0x0000191c
+#	define		NV50_TCL_PRIMITIVE_3D_CULL_FACE				0x00001920
+#	define		NV50_TCL_PRIMITIVE_3D_LOGIC_OP_ENABLE			0x000019c4
+#	define		NV50_TCL_PRIMITIVE_3D_LOGIC_OP_OP			0x000019c8
+#	define		NV50_TCL_PRIMITIVE_3D_CLEAR_BUFFERS			0x000019d0	/* Parameters: color stencil depth */
+#	define		NV50_TCL_PRIMITIVE_3D_COLOR_MASK( d)			(0x00001a00 + d * 0x0004)	/* Parameters: a b g r */
+
+/****************************************** 
 Object NV_DMA_FROM_MEMORY used on: NV03 NV04 NV10 NV15 NV20 NV30 NV40 G70
 */
 #define			NV_DMA_FROM_MEMORY					0x00000002
diff-tree 65e3d5e45e3d14f4ff98a15af0662e6c6e589cd2 (from 8d7e5651fba9fd62e1055c05d1814c7d2de7f43c)
Author: Stephane Marchesin <marchesin at icps.u-strasbg.fr>
Date:   Sun Jan 14 21:17:08 2007 +0100

    nouveau: Make the state cache hierarchical.

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fifo.h b/src/mesa/drivers/dri/nouveau/nouveau_fifo.h
index 05d00d4..9056bfb 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_fifo.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_fifo.h
@@ -31,6 +31,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "nouveau_context.h"
 #include "nouveau_ctrlreg.h"
+#include "nouveau_state_cache.h"
 
 //#define NOUVEAU_RING_DEBUG
 //#define NOUVEAU_STATE_CACHE_DISABLE
@@ -114,6 +115,7 @@ extern void nouveau_state_cache_init(nou
 #define OUT_RING_CACHE(n) do {									\
 	if (nmesa->state_cache.atoms[nmesa->state_cache.current_pos].value!=(n))	{	\
 		nmesa->state_cache.atoms[nmesa->state_cache.current_pos].dirty=1; 		\
+		nmesa->state_cache.hdirty[nmesa->state_cache.current_pos/NOUVEAU_STATE_CACHE_HIER_SIZE]=1; 		\
 		nmesa->state_cache.atoms[nmesa->state_cache.current_pos].value=(n);		\
 	}											\
 	nmesa->state_cache.current_pos++;							\
@@ -122,6 +124,7 @@ extern void nouveau_state_cache_init(nou
 #define OUT_RING_CACHEf(n) do {									\
 	if ((*(float*)(&nmesa->state_cache.atoms[nmesa->state_cache.current_pos].value))!=(n)){	\
 		nmesa->state_cache.atoms[nmesa->state_cache.current_pos].dirty=1;	 	\
+		nmesa->state_cache.hdirty[nmesa->state_cache.current_pos/NOUVEAU_STATE_CACHE_HIER_SIZE]=1; 		\
 		(*(float*)(&nmesa->state_cache.atoms[nmesa->state_cache.current_pos].value))=(n);\
 	}											\
 	nmesa->state_cache.current_pos++;							\
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state_cache.c b/src/mesa/drivers/dri/nouveau/nouveau_state_cache.c
index 36f0c10..cb4b9d3 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_state_cache.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_state_cache.c
@@ -25,6 +25,8 @@ void nouveau_state_cache_flush(nouveauCo
 	do
 	{
 		// jump to a dirty state
+		while((nmesa->state_cache.hdirty[i/NOUVEAU_STATE_CACHE_HIER_SIZE]==0)&&(i<NOUVEAU_STATE_CACHE_ENTRIES))
+			i=(i&~(NOUVEAU_STATE_CACHE_HIER_SIZE-1))+NOUVEAU_STATE_CACHE_HIER_SIZE;
 		while((nmesa->state_cache.atoms[i].dirty==0)&&(i<NOUVEAU_STATE_CACHE_ENTRIES))
 			i++;
 
@@ -42,11 +44,14 @@ void nouveau_state_cache_flush(nouveauCo
 			{
 				OUT_RING(nmesa->state_cache.atoms[i+j].value);
 				nmesa->state_cache.atoms[i+j].dirty=0;
+				if ((i+j)%NOUVEAU_STATE_CACHE_HIER_SIZE==0)
+					nmesa->state_cache.hdirty[(i+j)/NOUVEAU_STATE_CACHE_HIER_SIZE-1]=0;
 			}
 			i+=run;
 		}
 	}
 	while(i<NOUVEAU_STATE_CACHE_ENTRIES);
+	nmesa->state_cache.hdirty[NOUVEAU_STATE_CACHE_HIER_SIZE/NOUVEAU_STATE_CACHE_HIER_SIZE-1]=0;
 }
 
 
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state_cache.h b/src/mesa/drivers/dri/nouveau/nouveau_state_cache.h
index 2488274..5f9d426 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_state_cache.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_state_cache.h
@@ -5,6 +5,10 @@
 #include "mtypes.h"
 
 #define NOUVEAU_STATE_CACHE_ENTRIES 2048
+// size of a dirty requests block
+// you can play with that and tune the value to increase/decrease performance
+// but keep it a power of 2 !
+#define NOUVEAU_STATE_CACHE_HIER_SIZE  32
 
 typedef struct nouveau_state_atom_t{
 	uint32_t value;
@@ -14,8 +18,10 @@ typedef struct nouveau_state_atom_t{
 typedef struct nouveau_state_cache_t{
 	nouveau_state_atom atoms[NOUVEAU_STATE_CACHE_ENTRIES];
 	uint32_t current_pos;
+	// hierarchical dirty flags
+	uint8_t hdirty[NOUVEAU_STATE_CACHE_ENTRIES/NOUVEAU_STATE_CACHE_HIER_SIZE];
 	// master dirty flag
-	uint32_t dirty;
+	uint8_t dirty;
 }nouveau_state_cache;
 
 
diff-tree 8d7e5651fba9fd62e1055c05d1814c7d2de7f43c (from d57ce408b34b604f9b85114eedc88b5463df4218)
Author: Stephane Marchesin <marchesin at icps.u-strasbg.fr>
Date:   Sun Jan 14 20:37:57 2007 +0100

    nouveau: add the nv04 swtcl module (it's untested for now).

diff --git a/src/mesa/drivers/dri/nouveau/Makefile b/src/mesa/drivers/dri/nouveau/Makefile
index d31b42a..9eb40fb 100644
--- a/src/mesa/drivers/dri/nouveau/Makefile
+++ b/src/mesa/drivers/dri/nouveau/Makefile
@@ -26,6 +26,7 @@ DRIVER_SOURCES = \
 	nouveau_tex.c            \
 	nouveau_swtcl.c          \
 	nouveau_sync.c           \
+	nv04_swtcl.c             \
 	nv10_swtcl.c             \
 	nv10_state.c             \
 	nv20_state.c             \
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_swtcl.c b/src/mesa/drivers/dri/nouveau/nouveau_swtcl.c
index 746b0fa..f5c92a1 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_swtcl.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_swtcl.c
@@ -82,7 +82,7 @@ void nouveauFallback(struct nouveau_cont
 		nmesa->Fallback |= bit;
 		if (oldfallback == 0) {
 			if (nmesa->screen->card->type<NV_10) {
-				//nv03FinishPrimitive(nmesa);
+				//nv04FinishPrimitive(nmesa);
 			} else {
 				nv10FinishPrimitive(nmesa);
 			}
@@ -97,7 +97,7 @@ void nouveauFallback(struct nouveau_cont
 			_swrast_flush( ctx );
 
 			if (nmesa->screen->card->type<NV_10) {
-				//nv03TriInitFunctions(ctx);
+				//nv04TriInitFunctions(ctx);
 			} else {
 				nv10TriInitFunctions(ctx);
 			}
diff --git a/src/mesa/drivers/dri/nouveau/nv04_swtcl.c b/src/mesa/drivers/dri/nouveau/nv04_swtcl.c
new file mode 100644
index 0000000..e4ace92
--- /dev/null
+++ b/src/mesa/drivers/dri/nouveau/nv04_swtcl.c
@@ -0,0 +1,570 @@
+/*
+ * Copyright 2007 Stephane Marchesin. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/* Software TCL for NV04, NV05, NV06 */
+
+#include <stdio.h>
+#include <math.h>
+
+#include "glheader.h"
+#include "context.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "colormac.h"
+#include "enums.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+
+#include "nouveau_swtcl.h"
+#include "nv04_swtcl.h"
+#include "nouveau_context.h"
+#include "nouveau_span.h"
+#include "nouveau_reg.h"
+#include "nouveau_tex.h"
+#include "nouveau_fifo.h"
+#include "nouveau_msg.h"
+#include "nouveau_object.h"
+
+static void nv04RasterPrimitive( GLcontext *ctx, GLenum rprim, GLuint hwprim );
+static void nv04RenderPrimitive( GLcontext *ctx, GLenum prim );
+static void nv04ResetLineStipple( GLcontext *ctx );
+
+
+static inline void nv04_2triangles(struct nouveau_context *nmesa,nouveauVertex* v0,nouveauVertex* v1,nouveauVertex* v2,nouveauVertex* v3,nouveauVertex* v4,nouveauVertex* v5)
+{
+	BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0xA),49);
+	OUT_RINGp(v0,8);
+	OUT_RINGp(v1,8);
+	OUT_RINGp(v2,8);
+	OUT_RINGp(v3,8);
+	OUT_RINGp(v4,8);
+	OUT_RINGp(v5,8);
+	OUT_RING(0xFEDCBA);
+}
+
+static inline void nv04_1triangle(struct nouveau_context *nmesa,nouveauVertex* v0,nouveauVertex* v1,nouveauVertex* v2)
+{
+	BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0xD),25);
+	OUT_RINGp(v0,8);
+	OUT_RINGp(v1,8);
+	OUT_RINGp(v2,8);
+	OUT_RING(0xFED);
+}
+
+static inline void nv04_1quad(struct nouveau_context *nmesa,nouveauVertex* v0,nouveauVertex* v1,nouveauVertex* v2,nouveauVertex* v3)
+{
+	BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0xC),33);
+	OUT_RINGp(v0,8);
+	OUT_RINGp(v1,8);
+	OUT_RINGp(v2,8);
+	OUT_RINGp(v3,8);
+	OUT_RING(0xFECEDC);
+}
+
+/**********************************************************************/
+/*               Render unclipped begin/end objects                   */
+/**********************************************************************/
+
+static void nv04_render_points_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
+{
+	// erm
+}
+
+static void nv04_render_lines_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
+{
+	// umm
+}
+
+static void nv04_render_line_strip_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
+{
+	// yeah
+}
+
+static void nv04_render_line_loop_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
+{
+	// right
+}
+
+static void nv04_render_triangles_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
+{
+	struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
+	GLubyte *vertptr = (GLubyte *)nmesa->verts;
+	GLuint vertsize = nmesa->vertex_size;
+	int i;
+
+	for(i=start;i<count-5;i+=6)
+		nv04_2triangles(nmesa,
+				(nouveauVertex*)(vertptr+(i+0)*vertsize),
+				(nouveauVertex*)(vertptr+(i+1)*vertsize),
+				(nouveauVertex*)(vertptr+(i+2)*vertsize),
+				(nouveauVertex*)(vertptr+(i+3)*vertsize),
+				(nouveauVertex*)(vertptr+(i+4)*vertsize),
+				(nouveauVertex*)(vertptr+(i+5)*vertsize)
+			       );
+	if (i!=count)
+	{
+		nv04_1triangle(nmesa,
+				(nouveauVertex*)(vertptr+(i+0)*vertsize),
+				(nouveauVertex*)(vertptr+(i+1)*vertsize),
+				(nouveauVertex*)(vertptr+(i+2)*vertsize)
+			       );
+		i+=3;
+	}
+	if (i!=count)
+		printf("oops\n");
+}
+
+static void nv04_render_tri_strip_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
+{
+	struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
+	GLubyte *vertptr = (GLubyte *)nmesa->verts;
+	GLuint vertsize = nmesa->vertex_size;
+	uint32_t striptbl[]={0x321210,0x543432,0x765654,0x987876,0xBA9A98,0xDCBCBA,0xFEDEDC};
+	int i,j;
+
+	for(i=start;i<count;i+=14)
+	{
+		int numvert=MIN2(16,count-i);
+		int numtri=numvert-2;
+		if (numvert<3)
+			break;
+
+		BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0x0),numvert*8);
+		for(j=0;j<numvert;j++)
+			OUT_RINGp((nouveauVertex*)(vertptr+(i+j)*vertsize),8);
+
+		BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_DRAW|NONINC_METHOD,(numtri+1)/2);
+		for(j=0;j<numtri/2;j++)
+			OUT_RING(striptbl[j]);
+		if (numtri%2)
+			OUT_RING(striptbl[numtri/2]&0xFFF);
+	}
+}
+
+static void nv04_render_tri_fan_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
+{
+	struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
+	GLubyte *vertptr = (GLubyte *)nmesa->verts;
+	GLuint vertsize = nmesa->vertex_size;
+	uint32_t fantbl[]={0x320210,0x540430,0x760650,0x980870,0xBA0A90,0xDC0CB0,0xFE0ED0};
+	int i,j;
+
+	BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0x0),8);
+	OUT_RINGp((nouveauVertex*)(vertptr+start*vertsize),8);
+
+	for(i=start+1;i<count;i+=14)
+	{
+		int numvert=MIN2(15,count-i);
+		int numtri=numvert-2;
+		if (numvert<3)
+			break;
+
+		BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0x1),numvert*8);
+
+		for(j=0;j<numvert;j++)
+			OUT_RINGp((nouveauVertex*)(vertptr+(i+j)*vertsize),8);
+
+		BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_DRAW|NONINC_METHOD,(numtri+1)/2);
+		for(j=0;j<numtri/2;j++)
+			OUT_RING(fantbl[j]);
+		if (numtri%2)
+			OUT_RING(fantbl[numtri/2]&0xFFF);
+	}
+}
+
+static void nv04_render_quads_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
+{
+	struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
+	GLubyte *vertptr = (GLubyte *)nmesa->verts;
+	GLuint vertsize = nmesa->vertex_size;
+	int i;
+
+	for(i=start;i<count;i+=4)
+		nv04_1quad(nmesa,
+				(nouveauVertex*)(vertptr+(i+0)*vertsize),
+				(nouveauVertex*)(vertptr+(i+1)*vertsize),
+				(nouveauVertex*)(vertptr+(i+2)*vertsize),
+				(nouveauVertex*)(vertptr+(i+3)*vertsize)
+			       );
+}
+
+static void nv04_render_noop_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
+{
+}
+
+static void (*nv04_render_tab_verts[GL_POLYGON+2])(GLcontext *,
+							   GLuint,
+							   GLuint,
+							   GLuint) =
+{
+   nv04_render_points_verts,
+   nv04_render_lines_verts,
+   nv04_render_line_loop_verts,
+   nv04_render_line_strip_verts,
+   nv04_render_triangles_verts,
+   nv04_render_tri_strip_verts,
+   nv04_render_tri_fan_verts,
+   nv04_render_quads_verts,
+   nv04_render_tri_strip_verts,  //nv04_render_quad_strip_verts
+   nv04_render_tri_fan_verts,    //nv04_render_poly_verts
+   nv04_render_noop_verts,
+};
+
+
+static void nv04_render_points_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
+{
+	// erm
+}
+
+static void nv04_render_lines_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
+{
+	// umm
+}
+
+static void nv04_render_line_strip_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
+{
+	// yeah
+}
+
+static void nv04_render_line_loop_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
+{
+	// right
+}
+
+static void nv04_render_triangles_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
+{
+	struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
+	GLubyte *vertptr = (GLubyte *)nmesa->verts;
+	GLuint vertsize = nmesa->vertex_size;
+	const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts;
+	int i;
+
+	for(i=start;i<count-5;i+=6)
+		nv04_2triangles(nmesa,
+				(nouveauVertex*)(vertptr+elt[i+0]*vertsize),
+				(nouveauVertex*)(vertptr+elt[i+1]*vertsize),
+				(nouveauVertex*)(vertptr+elt[i+2]*vertsize),
+				(nouveauVertex*)(vertptr+elt[i+3]*vertsize),
+				(nouveauVertex*)(vertptr+elt[i+4]*vertsize),
+				(nouveauVertex*)(vertptr+elt[i+5]*vertsize)
+			       );
+	if (i!=count)
+	{
+		nv04_1triangle(nmesa,
+				(nouveauVertex*)(vertptr+elt[i+0]*vertsize),
+				(nouveauVertex*)(vertptr+elt[i+1]*vertsize),
+				(nouveauVertex*)(vertptr+elt[i+2]*vertsize)
+			       );
+		i+=3;
+	}
+	if (i!=count)
+		printf("oops\n");
+}
+
+static void nv04_render_tri_strip_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
+{
+	struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
+	GLubyte *vertptr = (GLubyte *)nmesa->verts;
+	GLuint vertsize = nmesa->vertex_size;
+	uint32_t striptbl[]={0x321210,0x543432,0x765654,0x987876,0xBA9A98,0xDCBCBA,0xFEDEDC};
+	const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts;
+	int i,j;
+
+	for(i=start;i<count;i+=14)
+	{
+		int numvert=MIN2(16,count-i);
+		int numtri=numvert-2;
+		if (numvert<3)
+			break;
+
+		BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0x0),numvert*8);
+		for(j=0;j<numvert;j++)
+			OUT_RINGp((nouveauVertex*)(vertptr+elt[i+j]*vertsize),8);
+
+		BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_DRAW|NONINC_METHOD,(numtri+1)/2);
+		for(j=0;j<numtri/2;j++)
+			OUT_RING(striptbl[j]);
+		if (numtri%2)
+			OUT_RING(striptbl[numtri/2]&0xFFF);
+	}
+}
+
+static void nv04_render_tri_fan_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
+{
+	struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
+	GLubyte *vertptr = (GLubyte *)nmesa->verts;
+	GLuint vertsize = nmesa->vertex_size;
+	uint32_t fantbl[]={0x320210,0x540430,0x760650,0x980870,0xBA0A90,0xDC0CB0,0xFE0ED0};
+	const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts;
+	int i,j;
+
+	BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0x0),8);
+	OUT_RINGp((nouveauVertex*)(vertptr+elt[start]*vertsize),8);
+
+	for(i=start+1;i<count;i+=14)
+	{
+		int numvert=MIN2(15,count-i);
+		int numtri=numvert-2;
+		if (numvert<3)
+			break;
+
+		BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0x1),numvert*8);
+
+		for(j=0;j<numvert;j++)
+			OUT_RINGp((nouveauVertex*)(vertptr+elt[i+j]*vertsize),8);
+
+		BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_DRAW|NONINC_METHOD,(numtri+1)/2);
+		for(j=0;j<numtri/2;j++)
+			OUT_RING(fantbl[j]);
+		if (numtri%2)
+			OUT_RING(fantbl[numtri/2]&0xFFF);
+	}
+}
+
+static void nv04_render_quads_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
+{
+	struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
+	GLubyte *vertptr = (GLubyte *)nmesa->verts;
+	GLuint vertsize = nmesa->vertex_size;
+	const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts;
+	int i;
+
+	for(i=start;i<count;i+=4)
+		nv04_1quad(nmesa,
+				(nouveauVertex*)(vertptr+elt[i+0]*vertsize),
+				(nouveauVertex*)(vertptr+elt[i+1]*vertsize),
+				(nouveauVertex*)(vertptr+elt[i+2]*vertsize),
+				(nouveauVertex*)(vertptr+elt[i+3]*vertsize)
+			       );
+}
+
+static void nv04_render_noop_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
+{
+}
+
+static void (*nv04_render_tab_elts[GL_POLYGON+2])(GLcontext *,
+							   GLuint,
+							   GLuint,
+							   GLuint) =
+{
+   nv04_render_points_elts,
+   nv04_render_lines_elts,
+   nv04_render_line_loop_elts,
+   nv04_render_line_strip_elts,
+   nv04_render_triangles_elts,
+   nv04_render_tri_strip_elts,
+   nv04_render_tri_fan_elts,
+   nv04_render_quads_elts,
+   nv04_render_tri_strip_elts,   // nv04_render_quad_strip_elts,
+   nv04_render_tri_fan_elts,     // nv04_render_poly_elts,
+   nv04_render_noop_elts,
+};
+
+
+/**********************************************************************/
+/*                    Choose render functions                         */
+/**********************************************************************/
+
+
+#define EMIT_ATTR( ATTR, STYLE )					\
+do {									\
+   nmesa->vertex_attrs[nmesa->vertex_attr_count].attrib = (ATTR);	\
+   nmesa->vertex_attrs[nmesa->vertex_attr_count].format = (STYLE);	\
+   nmesa->vertex_attr_count++;						\
+} while (0)
+
+#define EMIT_PAD( N )							\
+do {									\
+   nmesa->vertex_attrs[nmesa->vertex_attr_count].attrib = 0;		\
+   nmesa->vertex_attrs[nmesa->vertex_attr_count].format = EMIT_PAD;	\
+   nmesa->vertex_attrs[nmesa->vertex_attr_count].offset = (N);		\
+   nmesa->vertex_attr_count++;						\
+} while (0)
+
+
+static void nv04ChooseRenderState(GLcontext *ctx)
+{
+	TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+	tnl->Driver.Render.PrimTabVerts = nv04_render_tab_verts;
+	tnl->Driver.Render.PrimTabElts = nv04_render_tab_elts;
+	tnl->Driver.Render.ClippedLine = NULL;
+	tnl->Driver.Render.ClippedPolygon = NULL;
+}
+
+
+
+static inline void nv04OutputVertexFormat(struct nouveau_context* nmesa)
+{
+	GLcontext* ctx=nmesa->glCtx;
+	DECLARE_RENDERINPUTS(index);
+
+	/*
+	 * Tell t_vertex about the vertex format
+	 */
+	RENDERINPUTS_COPY(index, nmesa->render_inputs_bitset);
+
+	// SX SY SZ INVW
+	// FIXME : we use W instead of INVW, but since W=1 it doesn't matter
+	if (RENDERINPUTS_TEST(index, _TNL_ATTRIB_POS))
+		EMIT_ATTR(_TNL_ATTRIB_POS,EMIT_4F_VIEWPORT);
+	else
+		EMIT_PAD(4*sizeof(float));
+
+	// COLOR
+	if (RENDERINPUTS_TEST(index, _TNL_ATTRIB_COLOR0))
+		EMIT_ATTR(_TNL_ATTRIB_COLOR0,EMIT_4UB_4F_ABGR);
+	else
+		EMIT_PAD(4);
+
+	// SPECULAR
+	if (RENDERINPUTS_TEST(index, _TNL_ATTRIB_COLOR1))
+		EMIT_ATTR(_TNL_ATTRIB_COLOR1,EMIT_4UB_4F_ABGR);
+	else
+		EMIT_PAD(4);
+
+	// TEXTURE
+	if (RENDERINPUTS_TEST(index, _TNL_ATTRIB_TEX0))
+		EMIT_ATTR(_TNL_ATTRIB_TEX0,EMIT_2F);
+	else
+		EMIT_PAD(2*sizeof(float));
+
+	nmesa->vertex_size=_tnl_install_attrs( ctx,
+			nmesa->vertex_attrs, 
+			nmesa->vertex_attr_count,
+			ctx->Viewport._WindowMap.m, 0 );
+}
+
+
+static void nv04ChooseVertexState( GLcontext *ctx )
+{
+	struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
+	TNLcontext *tnl = TNL_CONTEXT(ctx);
+	DECLARE_RENDERINPUTS(index);
+
+	RENDERINPUTS_COPY(index, tnl->render_inputs_bitset);
+	if (!RENDERINPUTS_EQUAL(index, nmesa->render_inputs_bitset))
+	{
+		RENDERINPUTS_COPY(nmesa->render_inputs_bitset, index);
+		nv04OutputVertexFormat(nmesa);
+	}
+}
+
+
+/**********************************************************************/
+/*                 High level hooks for t_vb_render.c                 */
+/**********************************************************************/
+
+
+static void nv04RenderStart(GLcontext *ctx)
+{
+	struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
+
+	if (nmesa->new_state) {
+		nmesa->new_render_state |= nmesa->new_state;
+	}
+
+	if (nmesa->new_render_state) {
+		nv04ChooseVertexState(ctx);
+		nv04ChooseRenderState(ctx);
+		nmesa->new_render_state = 0;
+	}
+}
+
+static void nv04RenderFinish(GLcontext *ctx)
+{
+}
+
+
+/* System to flush dma and emit state changes based on the rasterized
+ * primitive.
+ */
+void nv04RasterPrimitive(GLcontext *ctx,
+		GLenum glprim,
+		GLuint hwprim)
+{
+	struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
+
+	assert (!nmesa->new_state);
+
+	if (hwprim != nmesa->current_primitive)
+	{
+		nmesa->current_primitive=hwprim;
+		
+	}
+}
+
+static const GLuint hw_prim[GL_POLYGON+1] = {
+	GL_POINTS+1,
+	GL_LINES+1,
+	GL_LINE_STRIP+1,
+	GL_LINE_LOOP+1,
+	GL_TRIANGLES+1,
+	GL_TRIANGLE_STRIP+1,
+	GL_TRIANGLE_FAN+1,
+	GL_QUADS+1,
+	GL_QUAD_STRIP+1,
+	GL_POLYGON+1
+};
+
+/* Callback for mesa:
+ */
+static void nv04RenderPrimitive( GLcontext *ctx, GLuint prim )
+{
+	nv04RasterPrimitive( ctx, prim, hw_prim[prim] );
+}
+
+static void nv04ResetLineStipple( GLcontext *ctx )
+{
+	/* FIXME do something here */
+	WARN_ONCE("Unimplemented nv04ResetLineStipple\n");
+}
+
+
+/**********************************************************************/
+/*                            Initialization.                         */
+/**********************************************************************/
+
+void nv04TriInitFunctions(GLcontext *ctx)
+{
+	struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
+	TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+	tnl->Driver.RunPipeline = nouveauRunPipeline;
+	tnl->Driver.Render.Start = nv04RenderStart;
+	tnl->Driver.Render.Finish = nv04RenderFinish;
+	tnl->Driver.Render.PrimitiveNotify = nv04RenderPrimitive;
+	tnl->Driver.Render.ResetLineStipple = nv04ResetLineStipple;
+	tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+	tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+	tnl->Driver.Render.Interp = _tnl_interp;
+
+	_tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12, 32 );
+
+	nmesa->verts = (GLubyte *)tnl->clipspace.vertex_buf;
+}
+
+
diff --git a/src/mesa/drivers/dri/nouveau/nv04_swtcl.h b/src/mesa/drivers/dri/nouveau/nv04_swtcl.h
new file mode 100644
index 0000000..42dde53
--- /dev/null
+++ b/src/mesa/drivers/dri/nouveau/nv04_swtcl.h
@@ -0,0 +1,12 @@
+#ifndef __NV04_SWTCL_H__
+#define __NV04_SWTCL_H__
+
+#include "mtypes.h"
+
+extern void nv04Fallback( GLcontext *ctx, GLuint bit, GLboolean mode );
+extern void nv04FinishPrimitive(struct nouveau_context *nmesa);
+extern void nv04TriInitFunctions(GLcontext *ctx);
+#define FALLBACK( nmesa, bit, mode ) nouveauFallback( nmesa->glCtx, bit, mode )
+
+#endif /* __NV04_SWTCL_H__ */
+
diff-tree d57ce408b34b604f9b85114eedc88b5463df4218 (from 81bd826de8897f3784ad301023bde6e7eb77b5b2)
Author: Stephane Marchesin <marchesin at icps.u-strasbg.fr>
Date:   Sat Jan 13 23:56:55 2007 +0100

    nouveau: Cleanup the nv10 swtcl module.

diff --git a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c
index 37d9f00..12b277d 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c
+++ b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c
@@ -56,9 +56,6 @@ static void nv10ResetLineStipple( GLcont
 
 
 
-/* the size above which we fire the ring. this is a performance-tunable */
-#define NOUVEAU_FIRE_SIZE (2048/4)
-
 static inline void nv10StartPrimitive(struct nouveau_context* nmesa,uint32_t primitive,uint32_t size)
 {
 	if (nmesa->screen->card->type==NV_10)
@@ -99,52 +96,6 @@ static inline void nv10ExtendPrimitive(s
 	}
 }
 
-static inline void nv10_draw_quad(nouveauContextPtr nmesa,
-		nouveauVertexPtr v0,
-		nouveauVertexPtr v1,
-		nouveauVertexPtr v2,
-		nouveauVertexPtr v3)
-{
-	GLuint vertsize = nmesa->vertex_size;
-	nv10ExtendPrimitive(nmesa, 4 * 4 * vertsize);
-
-	OUT_RINGp(v0,vertsize);
-	OUT_RINGp(v1,vertsize);
-	OUT_RINGp(v2,vertsize);
-	OUT_RINGp(v3,vertsize);
-}
-
-static inline void nv10_draw_triangle(nouveauContextPtr nmesa,
-		nouveauVertexPtr v0,
-		nouveauVertexPtr v1,
-		nouveauVertexPtr v2)
-{
-	GLuint vertsize = nmesa->vertex_size;
-	nv10ExtendPrimitive(nmesa, 3 * 4 * vertsize);
-
-	OUT_RINGp(v0,vertsize);
-	OUT_RINGp(v1,vertsize);
-	OUT_RINGp(v2,vertsize);
-}
-
-static inline void nv10_draw_line(nouveauContextPtr nmesa,
-		nouveauVertexPtr v0,
-		nouveauVertexPtr v1)
-{
-	GLuint vertsize = nmesa->vertex_size;
-	nv10ExtendPrimitive(nmesa, 2 * 4 * vertsize);
-	OUT_RINGp(v0,vertsize);
-	OUT_RINGp(v1,vertsize);
-}
-
-static inline void nv10_draw_point(nouveauContextPtr nmesa,
-		nouveauVertexPtr v0)
-{
-	GLuint vertsize = nmesa->vertex_size;
-	nv10ExtendPrimitive(nmesa, 1 * 4 * vertsize);
-	OUT_RINGp(v0,vertsize);
-}
-
 /**********************************************************************/
 /*               Render unclipped begin/end objects                   */
 /**********************************************************************/
@@ -343,10 +294,6 @@ static void nv10ChooseRenderState(GLcont
 	TNLcontext *tnl = TNL_CONTEXT(ctx);
 	struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
 
-	nmesa->draw_point = nv10_draw_point;
-	nmesa->draw_line = nv10_draw_line;
-	nmesa->draw_tri = nv10_draw_triangle;
-
 	tnl->Driver.Render.PrimTabVerts = nv10_render_tab_verts;
 	tnl->Driver.Render.PrimTabElts = nv10_render_tab_elts;
 	tnl->Driver.Render.ClippedLine = NULL;
@@ -538,11 +485,6 @@ static void nv10RenderStart(GLcontext *c
 		nmesa->new_render_state |= nmesa->new_state;
 	}
 
-	if (nmesa->Fallback) {
-		tnl->Driver.Render.Start(ctx);
-		return;
-	}
-
 	if (nmesa->new_render_state) {
 		nv10ChooseVertexState(ctx);
 		nv10ChooseRenderState(ctx);



More information about the mesa-commit mailing list