nouveau: a couple of NV3x fixes
authorBen Skeggs <darktama@iinet.net.au>
Tue, 6 Feb 2007 02:49:39 +0000 (13:49 +1100)
committerBen Skeggs <darktama@iinet.net.au>
Tue, 6 Feb 2007 03:01:19 +0000 (14:01 +1100)
src/mesa/drivers/dri/nouveau/nouveau_context.h
src/mesa/drivers/dri/nouveau/nouveau_shader.c
src/mesa/drivers/dri/nouveau/nv10_swtcl.c
src/mesa/drivers/dri/nouveau/nv30_fragprog.c
src/mesa/drivers/dri/nouveau/nv30_state.c

index c1d06654ee9d31e2481eeb5e27d49a277f96c077..f61fcbb48c0aa714a6c0590f1107827393f9314d 100644 (file)
@@ -159,6 +159,7 @@ typedef struct nouveau_context {
        nouveauShader *current_fragprog;
        nouveauShader *current_vertprog;
        nouveauShader *passthrough_vp;
+       nouveauShader *passthrough_fp;
 
        nouveauScreenRec *screen;
        drm_nouveau_sarea_t *sarea;
index c78b72bd11395a84a55777fac4be6283999087ee..ba471325aaa1efadf5f01612ea79a7f3e16f3e24 100644 (file)
@@ -220,6 +220,21 @@ nvsBuildPassthroughVP(GLcontext *ctx)
                                              vp_text);
 }
 
+static void
+nvsBuildPassthroughFP(GLcontext *ctx)
+{
+       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+
+       const char *fp_text =
+               "!!ARBfp1.0\n"
+               "MOV result.color, fragment.color;\n"
+               "END";
+
+       nmesa->passthrough_fp = nvsBuildTextShader(ctx,
+                                                  GL_FRAGMENT_PROGRAM_ARB,
+                                                  fp_text);
+}
+
 void
 nouveauShaderInitFuncs(GLcontext * ctx)
 {
@@ -249,6 +264,10 @@ nouveauShaderInitFuncs(GLcontext * ctx)
    if (nmesa->screen->card->type >= NV_40)
       nvsBuildPassthroughVP(ctx);
 
+   /* Needed on NV30, even when using swtcl, if you want to get colours */
+   if (nmesa->screen->card->type >= NV_30)
+      nvsBuildPassthroughFP(ctx);
+
    ctx->Const.VertexProgram.MaxNativeInstructions    = nmesa->VPfunc.MaxInst;
    ctx->Const.VertexProgram.MaxNativeAluInstructions = nmesa->VPfunc.MaxInst;
    ctx->Const.VertexProgram.MaxNativeTexInstructions = nmesa->VPfunc.MaxInst;
index eec67bd8059ad99e6eed0a7a2f734a84659b04af..32da40661b4fccd42e8df5a9f152114e1553ba28 100644 (file)
@@ -527,6 +527,16 @@ static void nv10ChooseVertexState( GLcontext *ctx )
                nv10OutputVertexFormat(nmesa);
        }
 
+       if (nmesa->screen->card->type == NV_30) {
+               nouveauShader *fp;
+               
+               if (ctx->FragmentProgram.Enabled) {
+                       fp = (nouveauShader *) ctx->FragmentProgram.Current;
+                       nvsUpdateShader(ctx, fp);
+               } else
+                       nvsUpdateShader(ctx, nmesa->passthrough_fp);
+       }
+
        if (nmesa->screen->card->type >= NV_40) {
                /* Ensure passthrough shader is being used, and mvp matrix
                 * is up to date
index f868ec9293184294cf542c118c5a4452575a38c4..e32452361e82592fec3df09cca77dd241df7c701 100644 (file)
@@ -46,9 +46,18 @@ NV30FPUploadToHW(GLcontext *ctx, nouveauShader *nvs)
     */
    BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_FP_ACTIVE_PROGRAM, 1);
    OUT_RING       (offset | 1);
-   BEGIN_RING_SIZE(NvSub3D, 0x1d60 /*NV30_TCL_PRIMITIVE_3D_FP_CONTROL*/, 1);
-   OUT_RING       ((priv->NV30FP.uses_kil <<  7) |
-                  (priv->NV30FP.num_regs << 24));
+   if (nmesa->screen->card->type == NV_30) {  
+          BEGIN_RING_SIZE(NvSub3D,
+                          0x1d60 /*NV30_TCL_PRIMITIVE_3D_FP_CONTROL*/, 1);
+          OUT_RING       ((priv->NV30FP.uses_kil << 7));
+          BEGIN_RING_SIZE(NvSub3D, 0x1450, 1);
+          OUT_RING       (priv->NV30FP.num_regs << 16);
+   } else {
+          BEGIN_RING_SIZE(NvSub3D,
+                          0x1d60 /*NV30_TCL_PRIMITIVE_3D_FP_CONTROL*/, 1);
+          OUT_RING       ((priv->NV30FP.uses_kil <<  7) |
+                          (priv->NV30FP.num_regs << 24));
+   }
 }
 
 static void
index 96a07fd53637cd84d4d731c75559e23b6661d701..ad21fa2730281dd4dc37cc60e58c18f1ea0c3068 100644 (file)
@@ -811,8 +811,6 @@ static GLboolean nv30InitCard(nouveauContextPtr nmesa)
        OUT_RING(0);
        BEGIN_RING_SIZE(NvSub3D, 0x1d80, 1);
        OUT_RING(3);
-       BEGIN_RING_SIZE(NvSub3D, 0x1450, 1);
-       OUT_RING(0x00030004);
        
        /* NEW */
                BEGIN_RING_SIZE(NvSub3D, 0x1e98, 1);
@@ -840,6 +838,9 @@ static GLboolean nv30InitCard(nouveauContextPtr nmesa)
         BEGIN_RING_SIZE(NvSub3D, 0x1d88, 1);
         OUT_RING(0x00001200);
 
+       BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_RC_ENABLE, 1);
+       OUT_RING       (0);
+
        return GL_TRUE;
 }