freedreno/a6xx: separate rast stateobj for prim restart
[mesa.git] / src / gallium / drivers / freedreno / a6xx / fd6_rasterizer.h
index afce6713b72446a73aaabb5c7e124ebfff38f5e4..22890b8def427bc0ed7a872c0afcfb45a2c9cd67 100644 (file)
 #include "pipe/p_state.h"
 #include "pipe/p_context.h"
 
+#include "freedreno_context.h"
+
 struct fd6_rasterizer_stateobj {
        struct pipe_rasterizer_state base;
 
-       uint32_t pc_primitive_cntl;
-
-       struct fd_ringbuffer *stateobj;
+       struct fd_ringbuffer *stateobjs[2];
 };
 
 static inline struct fd6_rasterizer_stateobj *
@@ -49,4 +49,21 @@ 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);
 
+struct fd_ringbuffer * __fd6_setup_rasterizer_stateobj(struct fd_context *ctx,
+               const struct pipe_rasterizer_state *cso, bool primitive_restart);
+
+static inline struct fd_ringbuffer *
+fd6_rasterizer_state(struct fd_context *ctx, bool primitive_restart)
+{
+       struct fd6_rasterizer_stateobj *rasterizer = fd6_rasterizer_stateobj(ctx->rasterizer);
+       unsigned variant = primitive_restart;
+
+       if (unlikely(!rasterizer->stateobjs[variant])) {
+               rasterizer->stateobjs[variant] =
+                       __fd6_setup_rasterizer_stateobj(ctx, ctx->rasterizer, primitive_restart);
+       }
+
+       return rasterizer->stateobjs[variant];
+}
+
 #endif /* FD6_RASTERIZER_H_ */