freedreno/a4xx: add polygon mode support
authorIlia Mirkin <imirkin@alum.mit.edu>
Sat, 21 Nov 2015 18:56:22 +0000 (13:56 -0500)
committerIlia Mirkin <imirkin@alum.mit.edu>
Mon, 23 Nov 2015 16:17:14 +0000 (11:17 -0500)
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/gallium/drivers/freedreno/a4xx/a4xx.xml.h
src/gallium/drivers/freedreno/a4xx/fd4_emit.c
src/gallium/drivers/freedreno/a4xx/fd4_rasterizer.c
src/gallium/drivers/freedreno/a4xx/fd4_rasterizer.h

index bd9b0a46bc19c68f130090621e94789708d22e12..df59438f106ce112bd9dec331251f122a99066b1 100644 (file)
@@ -2626,7 +2626,20 @@ static inline uint32_t A4XX_PC_PRIM_VTX_CNTL_VAROUT(uint32_t val)
 #define A4XX_PC_PRIM_VTX_CNTL_PROVOKING_VTX_LAST               0x02000000
 #define A4XX_PC_PRIM_VTX_CNTL_PSIZE                            0x04000000
 
-#define REG_A4XX_UNKNOWN_21C5                                  0x000021c5
+#define REG_A4XX_PC_PRIM_VTX_CNTL2                             0x000021c5
+#define A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_FRONT_PTYPE__MASK      0x00000007
+#define A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_FRONT_PTYPE__SHIFT     0
+static inline uint32_t A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_FRONT_PTYPE(enum adreno_pa_su_sc_draw val)
+{
+       return ((val) << A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_FRONT_PTYPE__SHIFT) & A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_FRONT_PTYPE__MASK;
+}
+#define A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_BACK_PTYPE__MASK       0x00000038
+#define A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_BACK_PTYPE__SHIFT      3
+static inline uint32_t A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_BACK_PTYPE(enum adreno_pa_su_sc_draw val)
+{
+       return ((val) << A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_BACK_PTYPE__SHIFT) & A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_BACK_PTYPE__MASK;
+}
+#define A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_ENABLE                 0x00000040
 
 #define REG_A4XX_PC_RESTART_INDEX                              0x000021c6
 
index 60069aeedc5d33c2803bb9d48b02f8491899ce82..ec454b2a10fbf79dc3ded5ab40294540e2ad67b6 100644 (file)
@@ -568,8 +568,9 @@ fd4_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
         */
        if (emit->info) {
                const struct pipe_draw_info *info = emit->info;
-               uint32_t val = fd4_rasterizer_stateobj(ctx->rasterizer)
-                               ->pc_prim_vtx_cntl;
+               struct fd4_rasterizer_stateobj *rast =
+                       fd4_rasterizer_stateobj(ctx->rasterizer);
+               uint32_t val = rast->pc_prim_vtx_cntl;
 
                if (info->indexed && info->primitive_restart)
                        val |= A4XX_PC_PRIM_VTX_CNTL_PRIMITIVE_RESTART;
@@ -585,7 +586,7 @@ fd4_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
 
                OUT_PKT0(ring, REG_A4XX_PC_PRIM_VTX_CNTL, 2);
                OUT_RING(ring, val);
-               OUT_RING(ring, 0x12);     /* XXX UNKNOWN_21C5 */
+               OUT_RING(ring, rast->pc_prim_vtx_cntl2);
        }
 
        if (dirty & FD_DIRTY_SCISSOR) {
index d894b6b9e096fd51af1461e9688457b8deac8952..7456c63febe46bcde0864856197bb279dd0fc35b 100644 (file)
@@ -77,6 +77,13 @@ fd4_rasterizer_state_create(struct pipe_context *pctx,
 
        so->gras_su_mode_control =
                        A4XX_GRAS_SU_MODE_CONTROL_LINEHALFWIDTH(cso->line_width/2.0);
+       so->pc_prim_vtx_cntl2 =
+               A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_FRONT_PTYPE(fd_polygon_mode(cso->fill_front)) |
+               A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_BACK_PTYPE(fd_polygon_mode(cso->fill_back));
+
+       if (cso->fill_front != PIPE_POLYGON_MODE_FILL ||
+               cso->fill_back != PIPE_POLYGON_MODE_FILL)
+               so->pc_prim_vtx_cntl2 |= A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_ENABLE;
 
        if (cso->cull_face & PIPE_FACE_FRONT)
                so->gras_su_mode_control |= A4XX_GRAS_SU_MODE_CONTROL_CULL_FRONT;
index 64e81a9983b70f52acaa0b6f1e174c7cead18481..b56a04da6a85aa580b4ee01726ac63635bde58bb 100644 (file)
@@ -42,6 +42,7 @@ struct fd4_rasterizer_stateobj {
        uint32_t gras_su_mode_control;
        uint32_t gras_cl_clip_cntl;
        uint32_t pc_prim_vtx_cntl;
+       uint32_t pc_prim_vtx_cntl2;
 };
 
 static inline struct fd4_rasterizer_stateobj *