nvc0: invalidate textures/samplers between 3D and CP on Fermi
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 26 May 2016 21:01:37 +0000 (23:01 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 26 May 2016 21:51:22 +0000 (23:51 +0200)
Like constant buffers, samplers and textures are aliased on Fermi and
we need to invalidate the state when switching from 3D to CP and vice
versa.

This fixes rendering issues in the UE4 demos.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/gallium/drivers/nouveau/nvc0/nvc0_compute.c
src/gallium/drivers/nouveau/nvc0/nvc0_tex.c

index 80d6f382dbaf269fc1113edf753c68750e571b7b..832c085356f484f4cbbaf877669da85eb80340e5 100644 (file)
@@ -124,6 +124,11 @@ nvc0_compute_validate_samplers(struct nvc0_context *nvc0)
       BEGIN_NVC0(nvc0->base.pushbuf, NVC0_CP(TSC_FLUSH), 1);
       PUSH_DATA (nvc0->base.pushbuf, 0);
    }
+
+   /* Invalidate all 3D samplers because they are aliased. */
+   for (int s = 0; s < 5; s++)
+      nvc0->samplers_dirty[s] = ~0;
+   nvc0->dirty_3d |= NVC0_NEW_3D_SAMPLERS;
 }
 
 static void
@@ -134,6 +139,14 @@ nvc0_compute_validate_textures(struct nvc0_context *nvc0)
       BEGIN_NVC0(nvc0->base.pushbuf, NVC0_CP(TIC_FLUSH), 1);
       PUSH_DATA (nvc0->base.pushbuf, 0);
    }
+
+   /* Invalidate all 3D textures because they are aliased. */
+   for (int s = 0; s < 5; s++) {
+      for (int i = 0; i < nvc0->num_textures[s]; i++)
+         nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_3D_TEX(s, i));
+      nvc0->textures_dirty[s] = ~0;
+   }
+   nvc0->dirty_3d |= NVC0_NEW_3D_TEXTURES;
 }
 
 static void
index 2523c20edc7071114ebe4a3f3760c763d88fa747..d36cea7a60c3826dcc687564b31aa7f5b66c47eb 100644 (file)
@@ -588,6 +588,14 @@ void nvc0_validate_textures(struct nvc0_context *nvc0)
       BEGIN_NVC0(nvc0->base.pushbuf, NVC0_3D(TIC_FLUSH), 1);
       PUSH_DATA (nvc0->base.pushbuf, 0);
    }
+
+   if (nvc0->screen->base.class_3d < NVE4_3D_CLASS) {
+      /* Invalidate all CP textures because they are aliased. */
+      for (int i = 0; i < nvc0->num_textures[5]; i++)
+         nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_CP_TEX(i));
+      nvc0->textures_dirty[5] = ~0;
+      nvc0->dirty_cp |= NVC0_NEW_CP_TEXTURES;
+   }
 }
 
 bool
@@ -700,6 +708,12 @@ void nvc0_validate_samplers(struct nvc0_context *nvc0)
       BEGIN_NVC0(nvc0->base.pushbuf, NVC0_3D(TSC_FLUSH), 1);
       PUSH_DATA (nvc0->base.pushbuf, 0);
    }
+
+   if (nvc0->screen->base.class_3d < NVE4_3D_CLASS) {
+      /* Invalidate all CP samplers because they are aliased. */
+      nvc0->samplers_dirty[5] = ~0;
+      nvc0->dirty_cp |= NVC0_NEW_CP_SAMPLERS;
+   }
 }
 
 /* Upload the "diagonal" entries for the possible texture sources ($t == $s).