1 /*
2 * Copyright © 2014 Rob Clark <[email protected]>
3 * SPDX-License-Identifier: MIT
4 *
5 * Authors:
6 * Rob Clark <[email protected]>
7 */
8
9 #ifndef FD4_EMIT_H
10 #define FD4_EMIT_H
11
12 #include "pipe/p_context.h"
13
14 #include "fd4_format.h"
15 #include "fd4_program.h"
16 #include "freedreno_context.h"
17 #include "ir3_gallium.h"
18
19 struct fd_ringbuffer;
20
21 void fd4_emit_gmem_restore_tex(struct fd_ringbuffer *ring, unsigned nr_bufs,
22 struct pipe_surface **bufs);
23
24 /* grouped together emit-state for prog/vertex/state emit: */
25 struct fd4_emit {
26 struct util_debug_callback *debug;
27 const struct fd_vertex_state *vtx;
28 const struct fd4_program_state *prog;
29 const struct pipe_draw_info *info;
30 unsigned drawid_offset;
31 const struct pipe_draw_indirect_info *indirect;
32 const struct pipe_draw_start_count_bias *draw;
33 bool binning_pass;
34 struct ir3_cache_key key;
35 enum fd_dirty_3d_state dirty;
36
37 uint32_t sprite_coord_enable; /* bitmask */
38 bool sprite_coord_mode;
39 bool rasterflat;
40 bool no_decode_srgb;
41 bool skip_consts;
42
43 /* cached to avoid repeated lookups of same variants: */
44 const struct ir3_shader_variant *vs, *fs;
45 /* TODO: other shader stages.. */
46 };
47
48 static inline enum a4xx_color_fmt
fd4_emit_format(struct pipe_surface * surf)49 fd4_emit_format(struct pipe_surface *surf)
50 {
51 if (!surf)
52 return 0;
53 return fd4_pipe2color(surf->format);
54 }
55
56 static inline const struct ir3_shader_variant *
fd4_emit_get_vp(struct fd4_emit * emit)57 fd4_emit_get_vp(struct fd4_emit *emit)
58 {
59 if (!emit->vs) {
60 emit->vs = emit->binning_pass ? emit->prog->bs : emit->prog->vs;
61 }
62 return emit->vs;
63 }
64
65 static inline const struct ir3_shader_variant *
fd4_emit_get_fp(struct fd4_emit * emit)66 fd4_emit_get_fp(struct fd4_emit *emit)
67 {
68 if (!emit->fs) {
69 if (emit->binning_pass) {
70 /* use dummy stateobj to simplify binning vs non-binning: */
71 static const struct ir3_shader_variant binning_fs = {};
72 emit->fs = &binning_fs;
73 } else {
74 emit->fs = emit->prog->fs;
75 }
76 }
77 return emit->fs;
78 }
79
80 void fd4_emit_vertex_bufs(struct fd_ringbuffer *ring,
81 struct fd4_emit *emit) assert_dt;
82
83 void fd4_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
84 struct fd4_emit *emit) assert_dt;
85
86 void fd4_emit_cs_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
87 struct ir3_shader_variant *cp) assert_dt;
88 void fd4_emit_cs_consts(const struct ir3_shader_variant *v,
89 struct fd_ringbuffer *ring, struct fd_context *ctx,
90 const struct pipe_grid_info *info) assert_dt;
91
92 void fd4_emit_restore(struct fd_batch *batch,
93 struct fd_ringbuffer *ring) assert_dt;
94
95 void fd4_emit_init_screen(struct pipe_screen *pscreen);
96 void fd4_emit_init(struct pipe_context *pctx);
97
98 static inline void
fd4_emit_ib(struct fd_ringbuffer * ring,struct fd_ringbuffer * target)99 fd4_emit_ib(struct fd_ringbuffer *ring, struct fd_ringbuffer *target)
100 {
101 __OUT_IB(ring, true, target);
102 }
103
104 #endif /* FD4_EMIT_H */
105