freedreno: Remove the Emacs mode lines
[mesa.git] / src / gallium / drivers / freedreno / a3xx / fd3_emit.h
1 /*
2 * Copyright (C) 2013 Rob Clark <robclark@freedesktop.org>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 *
23 * Authors:
24 * Rob Clark <robclark@freedesktop.org>
25 */
26
27 #ifndef FD3_EMIT_H
28 #define FD3_EMIT_H
29
30 #include "pipe/p_context.h"
31
32 #include "freedreno_context.h"
33 #include "fd3_format.h"
34 #include "fd3_program.h"
35 #include "ir3_shader.h"
36
37 struct fd_ringbuffer;
38
39 void fd3_emit_gmem_restore_tex(struct fd_ringbuffer *ring,
40 struct pipe_surface **psurf, int bufs);
41
42 /* grouped together emit-state for prog/vertex/state emit: */
43 struct fd3_emit {
44 struct pipe_debug_callback *debug;
45 const struct fd_vertex_state *vtx;
46 const struct fd_program_stateobj *prog;
47 const struct pipe_draw_info *info;
48 struct ir3_shader_key key;
49 enum fd_dirty_3d_state dirty;
50
51 uint32_t sprite_coord_enable;
52 bool sprite_coord_mode;
53 bool rasterflat;
54
55 /* cached to avoid repeated lookups of same variants: */
56 const struct ir3_shader_variant *vp, *fp;
57 };
58
59 static inline const struct ir3_shader_variant *
60 fd3_emit_get_vp(struct fd3_emit *emit)
61 {
62 if (!emit->vp) {
63 struct ir3_shader *shader = emit->prog->vp;
64 emit->vp = ir3_shader_variant(shader, emit->key, emit->debug);
65 }
66 return emit->vp;
67 }
68
69 static inline const struct ir3_shader_variant *
70 fd3_emit_get_fp(struct fd3_emit *emit)
71 {
72 if (!emit->fp) {
73 if (emit->key.binning_pass) {
74 /* use dummy stateobj to simplify binning vs non-binning: */
75 static const struct ir3_shader_variant binning_fp = {};
76 emit->fp = &binning_fp;
77 } else {
78 struct ir3_shader *shader = emit->prog->fp;
79 emit->fp = ir3_shader_variant(shader, emit->key, emit->debug);
80 }
81 }
82 return emit->fp;
83 }
84
85 void fd3_emit_vertex_bufs(struct fd_ringbuffer *ring, struct fd3_emit *emit);
86
87 void fd3_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
88 struct fd3_emit *emit);
89
90 void fd3_emit_restore(struct fd_batch *batch, struct fd_ringbuffer *ring);
91
92 void fd3_emit_init(struct pipe_context *pctx);
93
94 static inline void
95 fd3_emit_cache_flush(struct fd_batch *batch, struct fd_ringbuffer *ring)
96 {
97 fd_wfi(batch, ring);
98 OUT_PKT0(ring, REG_A3XX_UCHE_CACHE_INVALIDATE0_REG, 2);
99 OUT_RING(ring, A3XX_UCHE_CACHE_INVALIDATE0_REG_ADDR(0));
100 OUT_RING(ring, A3XX_UCHE_CACHE_INVALIDATE1_REG_ADDR(0) |
101 A3XX_UCHE_CACHE_INVALIDATE1_REG_OPCODE(INVALIDATE) |
102 A3XX_UCHE_CACHE_INVALIDATE1_REG_ENTIRE_CACHE);
103 }
104
105 #endif /* FD3_EMIT_H */