freedreno: Fix acc query handling in the presence of batch reordering.
[mesa.git] / src / gallium / drivers / freedreno / a6xx / fd6_rasterizer.c
index cc8b52c6a9f9c1ede551133a2873e813e01e5a74..2225ea0b2eb0b94c422dc9355e39669899be372a 100644 (file)
 #include "fd6_format.h"
 #include "fd6_pack.h"
 
-static struct fd_ringbuffer *
-setup_rasterizer_stateobj(struct fd_context *ctx,
-               const struct pipe_rasterizer_state *cso)
+struct fd_ringbuffer *
+__fd6_setup_rasterizer_stateobj(struct fd_context *ctx,
+               const struct pipe_rasterizer_state *cso, bool primitive_restart)
 {
-       struct fd_ringbuffer *ring = fd_ringbuffer_new_object(ctx->pipe, 12 * 4);
+       struct fd_ringbuffer *ring = fd_ringbuffer_new_object(ctx->pipe, 14 * 4);
        float psize_min, psize_max;
 
        if (cso->point_size_per_vertex) {
@@ -52,7 +52,7 @@ setup_rasterizer_stateobj(struct fd_context *ctx,
        }
 
        OUT_REG(ring,
-               A6XX_GRAS_UNKNOWN_8000(.unknown = 0x80),
+               A6XX_GRAS_CL_CNTL(.vp_clip_code_ignore = 1),
                A6XX_GRAS_UNKNOWN_8001());
 
        OUT_REG(ring,
@@ -85,6 +85,12 @@ setup_rasterizer_stateobj(struct fd_context *ctx,
                        cso->offset_clamp
                ));
 
+       OUT_REG(ring,
+               A6XX_PC_PRIMITIVE_CNTL_0(
+                       .provoking_vtx_last = !cso->flatshade_first,
+                       .primitive_restart = primitive_restart,
+               ));
+
        return ring;
 }
 
@@ -92,7 +98,6 @@ 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;
 
        so = CALLOC_STRUCT(fd6_rasterizer_stateobj);
@@ -101,11 +106,6 @@ fd6_rasterizer_state_create(struct pipe_context *pctx,
 
        so->base = *cso;
 
-       if (!cso->flatshade_first)
-               so->pc_primitive_cntl |= A6XX_PC_PRIMITIVE_CNTL_0_PROVOKING_VTX_LAST;
-
-       so->stateobj = setup_rasterizer_stateobj(ctx, cso);
-
        return so;
 }
 
@@ -114,7 +114,10 @@ fd6_rasterizer_state_delete(struct pipe_context *pctx, void *hwcso)
 {
        struct fd6_rasterizer_stateobj *so = hwcso;
 
-       fd_ringbuffer_del(so->stateobj);
+       for (unsigned i = 0; i < ARRAY_SIZE(so->stateobjs); i++)
+               if (so->stateobjs[i])
+                       fd_ringbuffer_del(so->stateobjs[i]);
+
        FREE(hwcso);
 }