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 c1d0665..f61fcbb 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 c78b72b..ba47132 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 eec67bd..32da406 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 f868ec9..e324523 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 96a07fd..ad21fa2 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;
 }