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_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 uint16_t num_viewports; 42 43 /** 44 * The # of shader stages that need driver params. 45 */ 46 uint8_t num_driver_params; 47 48 /** 49 * Output components from frag shader. It is possible to have 50 * a fragment shader that only writes a subset of the bound 51 * render targets. 52 */ 53 uint32_t mrt_components; 54 55 /** 56 * Rather than calculating user consts state size each draw, 57 * calculate it up-front. 58 */ 59 uint32_t user_consts_cmdstream_size; 60 61 /** 62 * The FS contribution to LRZ state 63 */ 64 struct fd6_lrz_state lrz_mask; 65 }; 66 67 static inline struct fd6_program_state * fd6_program_state(struct ir3_program_state * state)68fd6_program_state(struct ir3_program_state *state) 69 { 70 return (struct fd6_program_state *)state; 71 } 72 73 static inline const struct ir3_shader_variant * fd6_last_shader(const struct fd6_program_state * state)74fd6_last_shader(const struct fd6_program_state *state) 75 { 76 if (state->gs) 77 return state->gs; 78 else if (state->ds) 79 return state->ds; 80 else 81 return state->vs; 82 } 83 84 template <chip CHIP> 85 void fd6_emit_shader(struct fd_context *ctx, struct fd_ringbuffer *ring, 86 const struct ir3_shader_variant *so) assert_dt; 87 88 struct fd_ringbuffer *fd6_program_interp_state(struct fd6_emit *emit) assert_dt; 89 90 template <chip CHIP> 91 void fd6_prog_init(struct pipe_context *pctx); 92 93 #endif /* FD6_PROGRAM_H_ */ 94