• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 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 FD4_EMIT_H
28 #define FD4_EMIT_H
29 
30 #include "pipe/p_context.h"
31 
32 #include "fd4_format.h"
33 #include "fd4_program.h"
34 #include "freedreno_context.h"
35 #include "ir3_gallium.h"
36 
37 struct fd_ringbuffer;
38 
39 void fd4_emit_gmem_restore_tex(struct fd_ringbuffer *ring, unsigned nr_bufs,
40                                struct pipe_surface **bufs);
41 
42 /* grouped together emit-state for prog/vertex/state emit: */
43 struct fd4_emit {
44    struct pipe_debug_callback *debug;
45    const struct fd_vertex_state *vtx;
46    const struct fd4_program_state *prog;
47    const struct pipe_draw_info *info;
48 	unsigned drawid_offset;
49    const struct pipe_draw_indirect_info *indirect;
50 	const struct pipe_draw_start_count_bias *draw;
51    bool binning_pass;
52    struct ir3_cache_key key;
53    enum fd_dirty_3d_state dirty;
54 
55    uint32_t sprite_coord_enable; /* bitmask */
56    bool sprite_coord_mode;
57    bool rasterflat;
58    bool no_decode_srgb;
59    bool skip_consts;
60 
61    /* cached to avoid repeated lookups of same variants: */
62    const struct ir3_shader_variant *vs, *fs;
63    /* TODO: other shader stages.. */
64 };
65 
66 static inline enum a4xx_color_fmt
fd4_emit_format(struct pipe_surface * surf)67 fd4_emit_format(struct pipe_surface *surf)
68 {
69    if (!surf)
70       return 0;
71    return fd4_pipe2color(surf->format);
72 }
73 
74 static inline const struct ir3_shader_variant *
fd4_emit_get_vp(struct fd4_emit * emit)75 fd4_emit_get_vp(struct fd4_emit *emit)
76 {
77    if (!emit->vs) {
78       emit->vs = emit->binning_pass ? emit->prog->bs : emit->prog->vs;
79    }
80    return emit->vs;
81 }
82 
83 static inline const struct ir3_shader_variant *
fd4_emit_get_fp(struct fd4_emit * emit)84 fd4_emit_get_fp(struct fd4_emit *emit)
85 {
86    if (!emit->fs) {
87       if (emit->binning_pass) {
88          /* use dummy stateobj to simplify binning vs non-binning: */
89          static const struct ir3_shader_variant binning_fs = {};
90          emit->fs = &binning_fs;
91       } else {
92          emit->fs = emit->prog->fs;
93       }
94    }
95    return emit->fs;
96 }
97 
98 void fd4_emit_vertex_bufs(struct fd_ringbuffer *ring,
99                           struct fd4_emit *emit) assert_dt;
100 
101 void fd4_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
102                     struct fd4_emit *emit) assert_dt;
103 
104 void fd4_emit_restore(struct fd_batch *batch,
105                       struct fd_ringbuffer *ring) assert_dt;
106 
107 void fd4_emit_init_screen(struct pipe_screen *pscreen);
108 void fd4_emit_init(struct pipe_context *pctx);
109 
110 static inline void
fd4_emit_ib(struct fd_ringbuffer * ring,struct fd_ringbuffer * target)111 fd4_emit_ib(struct fd_ringbuffer *ring, struct fd_ringbuffer *target)
112 {
113    __OUT_IB(ring, true, target);
114 }
115 
116 #endif /* FD4_EMIT_H */
117