freedreno/a3xx: stencil fixes
authorRob Clark <robclark@freedesktop.org>
Sun, 8 Sep 2013 21:00:40 +0000 (17:00 -0400)
committerRob Clark <robclark@freedesktop.org>
Sat, 14 Sep 2013 17:31:58 +0000 (13:31 -0400)
For mem->gmem we don't sample depth/stencil as it's native type.  So we
need to setup the swizzle state for the sampler based on the format used
for sampling.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/gallium/drivers/freedreno/a2xx/a2xx.xml.h
src/gallium/drivers/freedreno/a3xx/a3xx.xml.h
src/gallium/drivers/freedreno/a3xx/fd3_draw.c
src/gallium/drivers/freedreno/a3xx/fd3_emit.c
src/gallium/drivers/freedreno/a3xx/fd3_util.c
src/gallium/drivers/freedreno/a3xx/fd3_util.h
src/gallium/drivers/freedreno/a3xx/fd3_zsa.c
src/gallium/drivers/freedreno/adreno_common.xml.h
src/gallium/drivers/freedreno/adreno_pm4.xml.h

index e99b753534cbb2aa1cff89b4551995044f186652..b4c12de9edb6ce64b995659f5a5c17295f969a18 100644 (file)
@@ -13,7 +13,7 @@ The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/a2xx/a2xx.xml           (  30005 bytes, from 2013-07-19 21:30:48)
 - /home/robclark/src/freedreno/envytools/rnndb/adreno_common.xml       (   8983 bytes, from 2013-07-24 01:38:36)
 - /home/robclark/src/freedreno/envytools/rnndb/adreno_pm4.xml          (   9759 bytes, from 2013-09-06 12:50:15)
-- /home/robclark/src/freedreno/envytools/rnndb/a3xx/a3xx.xml           (  51659 bytes, from 2013-09-08 18:21:13)
+- /home/robclark/src/freedreno/envytools/rnndb/a3xx/a3xx.xml           (  51947 bytes, from 2013-09-08 20:53:23)
 
 Copyright (C) 2013 by the following authors:
 - Rob Clark <robdclark@gmail.com> (robclark)
index 8eb7d6b4a26ad7e63cc1215ed295f0f35f0e5c2e..702b5f0b7ac3745dbdd7a9f7271ae9c85a052861 100644 (file)
@@ -13,7 +13,7 @@ The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/a2xx/a2xx.xml           (  30005 bytes, from 2013-07-19 21:30:48)
 - /home/robclark/src/freedreno/envytools/rnndb/adreno_common.xml       (   8983 bytes, from 2013-07-24 01:38:36)
 - /home/robclark/src/freedreno/envytools/rnndb/adreno_pm4.xml          (   9759 bytes, from 2013-09-06 12:50:15)
-- /home/robclark/src/freedreno/envytools/rnndb/a3xx/a3xx.xml           (  51659 bytes, from 2013-09-08 18:21:13)
+- /home/robclark/src/freedreno/envytools/rnndb/a3xx/a3xx.xml           (  51947 bytes, from 2013-09-08 20:53:23)
 
 Copyright (C) 2013 by the following authors:
 - Rob Clark <robdclark@gmail.com> (robclark)
@@ -1051,7 +1051,8 @@ static inline uint32_t A3XX_RB_DEPTH_PITCH(uint32_t val)
 
 #define REG_A3XX_RB_STENCIL_CONTROL                            0x00002104
 #define A3XX_RB_STENCIL_CONTROL_STENCIL_ENABLE                 0x00000001
-#define A3XX_RB_STENCIL_CONTROL_STENCIL_ENABLE_BF              0x00000004
+#define A3XX_RB_STENCIL_CONTROL_STENCIL_ENABLE_BF              0x00000002
+#define A3XX_RB_STENCIL_CONTROL_STENCIL_READ                   0x00000004
 #define A3XX_RB_STENCIL_CONTROL_FUNC__MASK                     0x00000700
 #define A3XX_RB_STENCIL_CONTROL_FUNC__SHIFT                    8
 static inline uint32_t A3XX_RB_STENCIL_CONTROL_FUNC(enum adreno_compare_func val)
index 720a813b8caeb4d9d7f342f39c4829a959424c72..e1f8067501b83a4c8283520eb34bfd18c43de9d5 100644 (file)
@@ -122,6 +122,7 @@ fd3_clear(struct fd_context *ctx, unsigned buffers,
                OUT_PKT0(ring, REG_A3XX_GRAS_CL_VPORT_ZOFFSET, 2);
                OUT_RING(ring, A3XX_GRAS_CL_VPORT_ZOFFSET(0.0));
                OUT_RING(ring, A3XX_GRAS_CL_VPORT_ZSCALE(depth));
+               ctx->dirty |= FD_DIRTY_VIEWPORT;
        } else {
                OUT_PKT0(ring, REG_A3XX_RB_DEPTH_CONTROL, 1);
                OUT_RING(ring, A3XX_RB_DEPTH_CONTROL_ZFUNC(FUNC_NEVER));
index 4492cce95e84870419d0efe59a90958a57476751..3cff18c7e640368bac2e52950651b0cd07dc99e7 100644 (file)
@@ -255,6 +255,7 @@ void
 fd3_emit_gmem_restore_tex(struct fd_ringbuffer *ring, struct pipe_surface *psurf)
 {
        struct fd_resource *rsc = fd_resource(psurf->texture);
+       enum pipe_format format = fd3_gmem_restore_format(psurf->format);
 
        /* output sampler state: */
        OUT_PKT3(ring, CP_LOAD_STATE, 4);
@@ -280,8 +281,8 @@ fd3_emit_gmem_restore_tex(struct fd_ringbuffer *ring, struct pipe_surface *psurf
        OUT_RING(ring, CP_LOAD_STATE_1_STATE_TYPE(ST_CONSTANTS) |
                        CP_LOAD_STATE_1_EXT_SRC_ADDR(0));
        OUT_RING(ring, A3XX_TEX_CONST_0_FMT(fd3_pipe2tex(psurf->format)) |
-                       0x40000000 | // XXX
-                       fd3_tex_swiz(psurf->format,  PIPE_SWIZZLE_RED, PIPE_SWIZZLE_GREEN,
+                       A3XX_TEX_CONST_0_TYPE(A3XX_TEX_2D) |
+                       fd3_tex_swiz(format,  PIPE_SWIZZLE_RED, PIPE_SWIZZLE_GREEN,
                                        PIPE_SWIZZLE_BLUE, PIPE_SWIZZLE_ALPHA));
        OUT_RING(ring, A3XX_TEX_CONST_1_FETCHSIZE(TFETCH_DISABLE) |
                        A3XX_TEX_CONST_1_WIDTH(psurf->width) |
index 6537fb77716f038a4c92a7456647bceda5f63b87..21ef43434f9eb36f02a3769d4cc3cb4e558c9933 100644 (file)
@@ -299,6 +299,24 @@ fd3_pipe2color(enum pipe_format format)
        }
 }
 
+/* we need to special case a bit the depth/stencil restore, because we are
+ * using the texture sampler to blit into the depth/stencil buffer, *not*
+ * into a color buffer.  Otherwise fd3_tex_swiz() will do the wrong thing,
+ * as it is assuming that you are sampling into normal render target..
+ */
+enum pipe_format
+fd3_gmem_restore_format(enum pipe_format format)
+{
+       switch (format) {
+       case PIPE_FORMAT_Z24X8_UNORM:
+       case PIPE_FORMAT_Z24_UNORM_S8_UINT:
+       case PIPE_FORMAT_Z16_UNORM:
+               return PIPE_FORMAT_B8G8R8A8_UNORM;
+       default:
+               return format;
+       }
+}
+
 enum a3xx_color_swap
 fd3_pipe2swap(enum pipe_format format)
 {
index e9ec15f5a3ff99371cebe4b1db24fd89f99181e5..0cc28d7b746178f081c835033b3e61b84ba17322 100644 (file)
@@ -37,6 +37,7 @@ enum a3xx_vtx_fmt fd3_pipe2vtx(enum pipe_format format);
 enum a3xx_tex_fmt fd3_pipe2tex(enum pipe_format format);
 enum a3xx_tex_fetchsize fd3_pipe2fetchsize(enum pipe_format format);
 enum a3xx_color_fmt fd3_pipe2color(enum pipe_format format);
+enum pipe_format fd3_gmem_restore_format(enum pipe_format format);
 enum a3xx_color_swap fd3_pipe2swap(enum pipe_format format);
 
 uint32_t fd3_tex_swiz(enum pipe_format format, unsigned swizzle_r,
index 15833ad1bef627715c5852229095cda5ab925cf3..c97cfb73695e63089c166ed78859ad2593b6a276 100644 (file)
@@ -62,6 +62,7 @@ fd3_zsa_state_create(struct pipe_context *pctx,
                const struct pipe_stencil_state *s = &cso->stencil[0];
 
                so->rb_stencil_control |=
+                       A3XX_RB_STENCIL_CONTROL_STENCIL_READ |
                        A3XX_RB_STENCIL_CONTROL_STENCIL_ENABLE |
                        A3XX_RB_STENCIL_CONTROL_FUNC(s->func) | /* maps 1:1 */
                        A3XX_RB_STENCIL_CONTROL_FAIL(fd_stencil_op(s->fail_op)) |
index 796f58d79973f21329e1fe108de5114aa482faf1..a46aa09e44bc777d7550705a1462b5eb40b54b8a 100644 (file)
@@ -13,7 +13,7 @@ The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/a2xx/a2xx.xml           (  30005 bytes, from 2013-07-19 21:30:48)
 - /home/robclark/src/freedreno/envytools/rnndb/adreno_common.xml       (   8983 bytes, from 2013-07-24 01:38:36)
 - /home/robclark/src/freedreno/envytools/rnndb/adreno_pm4.xml          (   9759 bytes, from 2013-09-06 12:50:15)
-- /home/robclark/src/freedreno/envytools/rnndb/a3xx/a3xx.xml           (  51659 bytes, from 2013-09-08 18:21:13)
+- /home/robclark/src/freedreno/envytools/rnndb/a3xx/a3xx.xml           (  51947 bytes, from 2013-09-08 20:53:23)
 
 Copyright (C) 2013 by the following authors:
 - Rob Clark <robdclark@gmail.com> (robclark)
index 8d981ec6eb52f8d09bf52999430d772e577807e0..3751722c2ba94ceae634a72ea235de5c8cc235ec 100644 (file)
@@ -13,7 +13,7 @@ The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/a2xx/a2xx.xml           (  30005 bytes, from 2013-07-19 21:30:48)
 - /home/robclark/src/freedreno/envytools/rnndb/adreno_common.xml       (   8983 bytes, from 2013-07-24 01:38:36)
 - /home/robclark/src/freedreno/envytools/rnndb/adreno_pm4.xml          (   9759 bytes, from 2013-09-06 12:50:15)
-- /home/robclark/src/freedreno/envytools/rnndb/a3xx/a3xx.xml           (  51659 bytes, from 2013-09-08 18:21:13)
+- /home/robclark/src/freedreno/envytools/rnndb/a3xx/a3xx.xml           (  51947 bytes, from 2013-09-08 20:53:23)
 
 Copyright (C) 2013 by the following authors:
 - Rob Clark <robdclark@gmail.com> (robclark)