xref: /aosp_15_r20/external/mesa3d/src/gallium/drivers/freedreno/a6xx/fd6_rasterizer.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2016 Rob Clark <[email protected]>
3  * Copyright © 2018 Google, Inc.
4  * SPDX-License-Identifier: MIT
5  *
6  * Authors:
7  *    Rob Clark <[email protected]>
8  */
9 
10 #ifndef FD6_RASTERIZER_H_
11 #define FD6_RASTERIZER_H_
12 
13 #include "pipe/p_context.h"
14 #include "pipe/p_state.h"
15 
16 #include "freedreno_context.h"
17 
18 struct fd6_rasterizer_stateobj {
19    struct pipe_rasterizer_state base;
20 
21    struct fd_ringbuffer *stateobjs[2];
22 };
23 
24 static inline struct fd6_rasterizer_stateobj *
fd6_rasterizer_stateobj(struct pipe_rasterizer_state * rast)25 fd6_rasterizer_stateobj(struct pipe_rasterizer_state *rast)
26 {
27    return (struct fd6_rasterizer_stateobj *)rast;
28 }
29 
30 void *fd6_rasterizer_state_create(struct pipe_context *pctx,
31                                   const struct pipe_rasterizer_state *cso);
32 void fd6_rasterizer_state_delete(struct pipe_context *, void *hwcso);
33 
34 template <chip CHIP>
35 struct fd_ringbuffer *
36 __fd6_setup_rasterizer_stateobj(struct fd_context *ctx,
37                                 const struct pipe_rasterizer_state *cso,
38                                 bool primitive_restart);
39 
40 template <chip CHIP>
41 static inline struct fd_ringbuffer *
fd6_rasterizer_state(struct fd_context * ctx,bool primitive_restart)42 fd6_rasterizer_state(struct fd_context *ctx, bool primitive_restart) assert_dt
43 {
44    struct fd6_rasterizer_stateobj *rasterizer =
45       fd6_rasterizer_stateobj(ctx->rasterizer);
46    unsigned variant = primitive_restart;
47 
48    if (unlikely(!rasterizer->stateobjs[variant])) {
49       rasterizer->stateobjs[variant] = __fd6_setup_rasterizer_stateobj<CHIP>(
50          ctx, ctx->rasterizer, primitive_restart);
51    }
52 
53    return rasterizer->stateobjs[variant];
54 }
55 
56 #endif /* FD6_RASTERIZER_H_ */
57