• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2016 Rob Clark <robclark@freedesktop.org>
3  * Copyright © 2018 Google, Inc.
4  * SPDX-License-Identifier: MIT
5  *
6  * Authors:
7  *    Rob Clark <robclark@freedesktop.org>
8  */
9 
10 #ifndef FD6_PROGRAM_H_
11 #define FD6_PROGRAM_H_
12 
13 #include "pipe/p_context.h"
14 #include "freedreno_context.h"
15 
16 #include "ir3/ir3_shader.h"
17 #include "ir3_cache.h"
18 
19 struct fd6_emit;
20 
21 struct fd6_program_state {
22    struct ir3_program_state base;
23    const struct ir3_shader_variant *bs; /* binning pass vs */
24    const struct ir3_shader_variant *vs;
25    const struct ir3_shader_variant *hs;
26    const struct ir3_shader_variant *ds;
27    const struct ir3_shader_variant *gs;
28    const struct ir3_shader_variant *fs;
29    struct fd_ringbuffer *config_stateobj;
30    struct fd_ringbuffer *interp_stateobj;
31    struct fd_ringbuffer *binning_stateobj;
32    struct fd_ringbuffer *streamout_stateobj;
33    struct fd_ringbuffer *stateobj;
34 
35    const struct ir3_stream_output_info *stream_output;
36 
37    /**
38     * Whether multiple viewports are used is determined by whether
39     * the last shader stage writes viewport id
40     */
41    uint8_t num_viewports;
42 
43    /**
44     * The # of shader stages that need driver params.
45     */
46    uint8_t num_driver_params;
47 
48    /**
49     * The # of shader stages that need ubo driver params
50     */
51    uint8_t num_ubo_driver_params;
52 
53    /**
54     * Output components from frag shader.  It is possible to have
55     * a fragment shader that only writes a subset of the bound
56     * render targets.
57     */
58    uint32_t mrt_components;
59 
60    /**
61     * Rather than calculating user consts state size each draw,
62     * calculate it up-front.
63     */
64    uint32_t user_consts_cmdstream_size;
65 
66    /**
67     * The FS contribution to LRZ state
68     */
69    struct fd6_lrz_state lrz_mask;
70 };
71 
72 static inline struct fd6_program_state *
fd6_program_state(struct ir3_program_state * state)73 fd6_program_state(struct ir3_program_state *state)
74 {
75    return (struct fd6_program_state *)state;
76 }
77 
78 static inline const struct ir3_shader_variant *
fd6_last_shader(const struct fd6_program_state * state)79 fd6_last_shader(const struct fd6_program_state *state)
80 {
81    if (state->gs)
82       return state->gs;
83    else if (state->ds)
84       return state->ds;
85    else
86       return state->vs;
87 }
88 
89 template <chip CHIP>
90 void fd6_emit_shader(struct fd_context *ctx, struct fd_ringbuffer *ring,
91                      const struct ir3_shader_variant *so) assert_dt;
92 
93 struct fd_ringbuffer *fd6_program_interp_state(struct fd6_emit *emit) assert_dt;
94 
95 template <chip CHIP>
96 void fd6_prog_init(struct pipe_context *pctx);
97 
98 #endif /* FD6_PROGRAM_H_ */
99