[Mesa-dev] [PATCH 2/3] nv50, nvc0: add support for stencil sampling from depth_stencil textures

Ilia Mirkin imirkin at alum.mit.edu
Fri May 2 19:42:33 PDT 2014


Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
 src/gallium/drivers/nouveau/nv50/nv50_tex.c | 12 ++++++++++++
 src/gallium/drivers/nouveau/nvc0/nvc0_tex.c | 12 ++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/src/gallium/drivers/nouveau/nv50/nv50_tex.c b/src/gallium/drivers/nouveau/nv50/nv50_tex.c
index 5cfce3a..acb28fd 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_tex.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_tex.c
@@ -103,6 +103,18 @@ nv50_create_texture_view(struct pipe_context *pipe,
 
    tex_int = util_format_is_pure_integer(view->pipe.format);
 
+   if (templ->stencil_sampling) {
+      /* flip between C0 and C1 for r */
+      tic[0] ^= 1 << NV50_TIC_0_MAPR__SHIFT;
+      /* clear out g/b/a */
+      tic[0] &= ~(NV50_TIC_0_MAPG__MASK |
+                  NV50_TIC_0_MAPB__MASK |
+                  NV50_TIC_0_MAPA__MASK);
+      /* set a to 1 */
+      tic[0] |= NV50_TIC_MAP_ONE_INT << NV50_TIC_0_MAPA__SHIFT;
+      tex_int = 1;
+   }
+
    swz[0] = nv50_tic_swizzle(tic[0], view->pipe.swizzle_r, tex_int);
    swz[1] = nv50_tic_swizzle(tic[0], view->pipe.swizzle_g, tex_int);
    swz[2] = nv50_tic_swizzle(tic[0], view->pipe.swizzle_b, tex_int);
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_tex.c b/src/gallium/drivers/nouveau/nvc0/nvc0_tex.c
index 1b11bd0..ef0047f 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_tex.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_tex.c
@@ -106,6 +106,18 @@ nvc0_create_texture_view(struct pipe_context *pipe,
 
    tex_int = util_format_is_pure_integer(view->pipe.format);
 
+   if (templ->stencil_sampling) {
+      /* flip between C0 and C1 for r */
+      tic[0] ^= 1 << NV50_TIC_0_MAPR__SHIFT;
+      /* clear out g/b/a */
+      tic[0] &= ~(NV50_TIC_0_MAPG__MASK |
+                  NV50_TIC_0_MAPB__MASK |
+                  NV50_TIC_0_MAPA__MASK);
+      /* set a to 1 */
+      tic[0] |= NV50_TIC_MAP_ONE_INT << NV50_TIC_0_MAPA__SHIFT;
+      tex_int = 1;
+   }
+
    swz[0] = nv50_tic_swizzle(tic[0], view->pipe.swizzle_r, tex_int);
    swz[1] = nv50_tic_swizzle(tic[0], view->pipe.swizzle_g, tex_int);
    swz[2] = nv50_tic_swizzle(tic[0], view->pipe.swizzle_b, tex_int);
-- 
1.8.3.2



More information about the mesa-dev mailing list