freedreno/a6xx: Move rasterizer state to state object
authorKristian H. Kristensen <hoegsberg@chromium.org>
Mon, 22 Oct 2018 16:35:39 +0000 (09:35 -0700)
committerRob Clark <robdclark@gmail.com>
Fri, 26 Oct 2018 22:10:00 +0000 (18:10 -0400)
Signed-off-by: Kristian H. Kristensen <hoegsberg@chromium.org>
src/gallium/drivers/freedreno/a6xx/fd6_context.c
src/gallium/drivers/freedreno/a6xx/fd6_emit.c
src/gallium/drivers/freedreno/a6xx/fd6_emit.h
src/gallium/drivers/freedreno/a6xx/fd6_rasterizer.c
src/gallium/drivers/freedreno/a6xx/fd6_rasterizer.h

index 33f769619f316e39e5e8244e63c81462f1d4b4df..b55b6f6934f50d3137ef2dca526ccbeb1428bcde 100644 (file)
@@ -104,6 +104,10 @@ fd6_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
        if (!pctx)
                return NULL;
 
+       /* fd_context_init overwrites delete_rasterizer_state, so set this
+        * here. */
+       pctx->delete_rasterizer_state = fd6_rasterizer_state_delete;
+
        fd6_ctx->vs_pvt_mem = fd_bo_new(screen->dev, 0x2000,
                        DRM_FREEDRENO_GEM_TYPE_KMEM);
 
index e2781ce1862575c94dd09a253179c84c0b66f9be..5fb3a04034d49ece1d9b90040e1f4f03fcb5affd 100644 (file)
@@ -715,33 +715,8 @@ fd6_emit_state(struct fd_ringbuffer *ring, struct fd6_emit *emit)
        if (dirty & FD_DIRTY_RASTERIZER) {
                struct fd6_rasterizer_stateobj *rasterizer =
                                fd6_rasterizer_stateobj(ctx->rasterizer);
-
-               OUT_PKT4(ring, REG_A6XX_GRAS_UNKNOWN_8000, 1);
-               OUT_RING(ring, 0x80);
-               OUT_PKT4(ring, REG_A6XX_GRAS_UNKNOWN_8001, 1);
-               OUT_RING(ring, 0x0);
-               OUT_PKT4(ring, REG_A6XX_GRAS_UNKNOWN_8004, 1);
-               OUT_RING(ring, 0x0);
-
-               OUT_PKT4(ring, REG_A6XX_GRAS_SU_CNTL, 1);
-               OUT_RING(ring, rasterizer->gras_su_cntl);
-
-               OUT_PKT4(ring, REG_A6XX_GRAS_SU_POINT_MINMAX, 2);
-               OUT_RING(ring, rasterizer->gras_su_point_minmax);
-               OUT_RING(ring, rasterizer->gras_su_point_size);
-
-               OUT_PKT4(ring, REG_A6XX_GRAS_SU_POLY_OFFSET_SCALE, 3);
-               OUT_RING(ring, rasterizer->gras_su_poly_offset_scale);
-               OUT_RING(ring, rasterizer->gras_su_poly_offset_offset);
-               OUT_RING(ring, rasterizer->gras_su_poly_offset_clamp);
-
-#if 0
-               OUT_PKT4(ring, REG_A6XX_PC_RASTER_CNTL, 1);
-               OUT_RING(ring, rasterizer->pc_raster_cntl);
-
-               OUT_PKT4(ring, REG_A6XX_GRAS_CL_CNTL, 1);
-               OUT_RING(ring, rasterizer->gras_cl_clip_cntl);
-#endif
+               fd6_emit_add_group(emit, rasterizer->stateobj,
+                                                  FD6_GROUP_RASTERIZER, 0x7);
        }
 
        /* Since the primitive restart state is not part of a tracked object, we
index 7fe6b55736f5c71621d668269a9a24f33b0d841b..745be6a5996f80fef874826886681088222e1fab 100644 (file)
@@ -53,6 +53,7 @@ enum fd6_state_id {
        FD6_GROUP_FS_CONST,
        FD6_GROUP_VS_TEX,
        FD6_GROUP_FS_TEX,
+       FD6_GROUP_RASTERIZER,
 };
 
 struct fd6_state_group {
index 7f13676799be6e882b65411ab1341e0c2fdda6d3..26bb567f65ce0dc37b7582e1fe7b019533aa4170 100644 (file)
@@ -38,6 +38,7 @@ void *
 fd6_rasterizer_state_create(struct pipe_context *pctx,
                const struct pipe_rasterizer_state *cso)
 {
+       struct fd_context *ctx = fd_context(pctx);
        struct fd6_rasterizer_stateobj *so;
        float psize_min, psize_max;
 
@@ -101,5 +102,45 @@ fd6_rasterizer_state_create(struct pipe_context *pctx,
                so->gras_cl_clip_cntl |= A6XX_GRAS_CL_CNTL_ZERO_GB_SCALE_Z;
 #endif
 
+       so->stateobj = fd_ringbuffer_new_object(ctx->pipe, 15 * 4);
+       struct fd_ringbuffer *ring = so->stateobj;
+
+       OUT_PKT4(ring, REG_A6XX_GRAS_UNKNOWN_8000, 1);
+       OUT_RING(ring, 0x80);
+       OUT_PKT4(ring, REG_A6XX_GRAS_UNKNOWN_8001, 1);
+       OUT_RING(ring, 0x0);
+       OUT_PKT4(ring, REG_A6XX_GRAS_UNKNOWN_8004, 1);
+       OUT_RING(ring, 0x0);
+
+       OUT_PKT4(ring, REG_A6XX_GRAS_SU_CNTL, 1);
+       OUT_RING(ring, so->gras_su_cntl);
+
+       OUT_PKT4(ring, REG_A6XX_GRAS_SU_POINT_MINMAX, 2);
+       OUT_RING(ring, so->gras_su_point_minmax);
+       OUT_RING(ring, so->gras_su_point_size);
+
+       OUT_PKT4(ring, REG_A6XX_GRAS_SU_POLY_OFFSET_SCALE, 3);
+       OUT_RING(ring, so->gras_su_poly_offset_scale);
+       OUT_RING(ring, so->gras_su_poly_offset_offset);
+       OUT_RING(ring, so->gras_su_poly_offset_clamp);
+
+#if 0
+       OUT_PKT4(ring, REG_A6XX_PC_RASTER_CNTL, 1);
+       OUT_RING(ring, so->pc_raster_cntl);
+
+       OUT_PKT4(ring, REG_A6XX_GRAS_CL_CNTL, 1);
+       OUT_RING(ring, so->gras_cl_clip_cntl);
+#endif
+
        return so;
 }
+
+void
+fd6_rasterizer_state_delete(struct pipe_context *pctx, void *hwcso)
+{
+       struct fd6_rasterizer_stateobj *so = hwcso;
+
+       fd_ringbuffer_del(so->stateobj);
+       FREE(hwcso);
+}
+
index d2020bee3775216fdc9dcef843f03c4231b6f81c..1fecfb6cd833255f5c9b15f78a631f1b91d59784 100644 (file)
@@ -44,6 +44,8 @@ struct fd6_rasterizer_stateobj {
        uint32_t gras_cl_clip_cntl;
        uint32_t pc_primitive_cntl;
        uint32_t pc_raster_cntl;
+
+       struct fd_ringbuffer *stateobj;
 };
 
 static inline struct fd6_rasterizer_stateobj *
@@ -54,5 +56,6 @@ fd6_rasterizer_stateobj(struct pipe_rasterizer_state *rast)
 
 void * fd6_rasterizer_state_create(struct pipe_context *pctx,
                const struct pipe_rasterizer_state *cso);
+void fd6_rasterizer_state_delete(struct pipe_context *, void *hwcso);
 
 #endif /* FD6_RASTERIZER_H_ */