xref: /aosp_15_r20/external/mesa3d/src/gallium/drivers/freedreno/a6xx/fd6_zsa.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_ZSA_H_
11 #define FD6_ZSA_H_
12 
13 #include "pipe/p_context.h"
14 #include "pipe/p_state.h"
15 
16 #include "freedreno_util.h"
17 
18 #include "fd6_context.h"
19 
20 #define FD6_ZSA_NO_ALPHA    (1 << 0)
21 #define FD6_ZSA_DEPTH_CLAMP (1 << 1)
22 
23 struct fd6_zsa_stateobj {
24    struct pipe_depth_stencil_alpha_state base;
25 
26    uint32_t rb_alpha_control;
27    uint32_t rb_depth_cntl;
28    uint32_t rb_stencil_control;
29    uint32_t rb_stencilmask;
30    uint32_t rb_stencilwrmask;
31 
32    struct fd6_lrz_state lrz;
33    bool writes_zs : 1; /* writes depth and/or stencil */
34    bool writes_z : 1;  /* writes depth */
35    bool invalidate_lrz : 1;
36    bool alpha_test : 1;
37 
38    /* Track whether we've alread generated perf warns so that
39     * we don't flood the user with LRZ disable warns which can
40     * only be detected at draw time.
41     */
42    bool perf_warn_blend : 1;
43    bool perf_warn_zdir : 1;
44 
45    struct fd_ringbuffer *stateobj[4];
46 };
47 
48 static inline struct fd6_zsa_stateobj *
fd6_zsa_stateobj(struct pipe_depth_stencil_alpha_state * zsa)49 fd6_zsa_stateobj(struct pipe_depth_stencil_alpha_state *zsa)
50 {
51    return (struct fd6_zsa_stateobj *)zsa;
52 }
53 
54 static inline struct fd_ringbuffer *
fd6_zsa_state(struct fd_context * ctx,bool no_alpha,bool depth_clamp)55 fd6_zsa_state(struct fd_context *ctx, bool no_alpha, bool depth_clamp) assert_dt
56 {
57    int variant = 0;
58    if (no_alpha)
59       variant |= FD6_ZSA_NO_ALPHA;
60    if (depth_clamp)
61       variant |= FD6_ZSA_DEPTH_CLAMP;
62    return fd6_zsa_stateobj(ctx->zsa)->stateobj[variant];
63 }
64 
65 template <chip CHIP>
66 void *fd6_zsa_state_create(struct pipe_context *pctx,
67                            const struct pipe_depth_stencil_alpha_state *cso);
68 
69 void fd6_zsa_state_delete(struct pipe_context *pctx, void *hwcso);
70 
71 #endif /* FD6_ZSA_H_ */
72