Debian Codegraph @

src/gallium/drivers/nouveau/nv30/nv30_context.h

raw
1 #ifndef __NV30_CONTEXT_H__
2 #define __NV30_CONTEXT_H__
3
4 #include "util/format/u_formats.h"
5 #include "util/u_blitter.h"
6 #include "util/u_framebuffer.h"
7
8 #include "nv30/nv30_screen.h"
9 #include "nv30/nv30_state.h"
10
11 #include "nouveau_context.h"
12
13 #define BUFCTX_FB 0
14 #define BUFCTX_VTXTMP 1
15 #define BUFCTX_VTXBUF 2
16 #define BUFCTX_IDXBUF 3
17 #define BUFCTX_VERTTEX(n) (4 + (n))
18 #define BUFCTX_FRAGPROG 8
19 #define BUFCTX_FRAGTEX(n) (9 + (n))
20
21 #define NV30_NEW_BLEND (1 << 0)
22 #define NV30_NEW_RASTERIZER (1 << 1)
23 #define NV30_NEW_ZSA (1 << 2)
24 #define NV30_NEW_VERTPROG (1 << 3)
25 #define NV30_NEW_VERTCONST (1 << 4)
26 #define NV30_NEW_FRAGPROG (1 << 5)
27 #define NV30_NEW_FRAGCONST (1 << 6)
28 #define NV30_NEW_BLEND_COLOUR (1 << 7)
29 #define NV30_NEW_STENCIL_REF (1 << 8)
30 #define NV30_NEW_CLIP (1 << 9)
31 #define NV30_NEW_SAMPLE_MASK (1 << 10)
32 #define NV30_NEW_FRAMEBUFFER (1 << 11)
33 #define NV30_NEW_STIPPLE (1 << 12)
34 #define NV30_NEW_SCISSOR (1 << 13)
35 #define NV30_NEW_VIEWPORT (1 << 14)
36 #define NV30_NEW_ARRAYS (1 << 15)
37 #define NV30_NEW_VERTEX (1 << 16)
38 #define NV30_NEW_CONSTBUF (1 << 17)
39 #define NV30_NEW_FRAGTEX (1 << 18)
40 #define NV30_NEW_VERTTEX (1 << 19)
41 #define NV30_NEW_SWTNL (1 << 31)
42 #define NV30_NEW_ALL 0x000fffff
43
44 struct nv30_context {
45 struct nouveau_context base;
46 struct nv30_screen *screen;
47 struct blitter_context *blitter;
48
49 struct nouveau_bufctx *bufctx;
50
51 struct {
52 unsigned rt_enable;
53 unsigned scissor_off;
54 unsigned num_vtxelts;
55 int index_bias;
56 bool prim_restart;
57 struct nv30_fragprog *fragprog;
58 } state;
59
60 uint32_t dirty;
61
62 struct draw_context *draw;
63 uint32_t draw_flags;
64 uint32_t draw_dirty;
65
66 struct nv30_blend_stateobj *blend;
67 struct nv30_rasterizer_stateobj *rast;
68 struct nv30_zsa_stateobj *zsa;
69 struct nv30_vertex_stateobj *vertex;
70
71 struct {
72 unsigned filter;
73 unsigned aniso;
74 } config;
75
76 struct {
77 struct nv30_vertprog *program;
78
79 struct pipe_resource *constbuf;
80 unsigned constbuf_nr;
81
82 struct pipe_sampler_view *textures[PIPE_MAX_SAMPLERS];
83 unsigned num_textures;
84 struct nv30_sampler_state *samplers[PIPE_MAX_SAMPLERS];
85 unsigned num_samplers;
86 unsigned dirty_samplers;
87 } vertprog;
88
89 struct {
90 struct nv30_fragprog *program;
91
92 struct pipe_resource *constbuf;
93 unsigned constbuf_nr;
94
95 struct pipe_sampler_view *textures[PIPE_MAX_SAMPLERS];
96 unsigned num_textures;
97 struct nv30_sampler_state *samplers[PIPE_MAX_SAMPLERS];
98 unsigned num_samplers;
99 unsigned dirty_samplers;
100 } fragprog;
101
102 struct pipe_surface *fb_cbufs[PIPE_MAX_COLOR_BUFS];
103 struct pipe_surface *fb_zsbuf;
104 struct pipe_framebuffer_state framebuffer;
105 struct pipe_blend_color blend_colour;
106 struct pipe_stencil_ref stencil_ref;
107 struct pipe_poly_stipple stipple;
108 struct pipe_scissor_state scissor;
109 struct pipe_viewport_state viewport;
110 struct pipe_clip_state clip;
111
112 unsigned sample_mask;
113
114 struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
115 unsigned num_vtxbufs;
116 uint32_t vbo_fifo;
117 uint32_t vbo_user;
118 unsigned vbo_min_index;
119 unsigned vbo_max_index;
120 bool vbo_push_hint;
121
122 struct nouveau_heap *blit_vp;
123 struct pipe_resource *blit_fp;
124
125 struct pipe_query *render_cond_query;
126 unsigned render_cond_mode;
127 bool render_cond_cond;
128 };
129
130 static inline struct nv30_context *
131 nv30_context(struct pipe_context *pipe)
132 {
133 return (struct nv30_context *)pipe;
134 }
135
136 struct pipe_context *
137 nv30_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags);
138
139 void
140 nv30_vbo_init(struct pipe_context *pipe);
141
142 void
143 nv30_vbo_validate(struct nv30_context *nv30);
144
145 void
146 nv30_query_init(struct pipe_context *pipe);
147
148 void
149 nv30_state_init(struct pipe_context *pipe);
150
151 void
152 nv30_clear_init(struct pipe_context *pipe);
153
154 void
155 nv30_vertprog_init(struct pipe_context *pipe);
156
157 void
158 nv30_vertprog_validate(struct nv30_context *nv30);
159
160 void
161 nv30_fragprog_init(struct pipe_context *pipe);
162
163 void
164 nv30_fragprog_validate(struct nv30_context *nv30);
165
166 void
167 nv30_texture_init(struct pipe_context *pipe);
168
169 void
170 nv30_texture_validate(struct nv30_context *nv30);
171
172 void
173 nv30_fragtex_init(struct pipe_context *pipe);
174
175 void
176 nv30_fragtex_validate(struct nv30_context *nv30);
177
178 void
179 nv40_verttex_init(struct pipe_context *pipe);
180
181 void
182 nv40_verttex_validate(struct nv30_context *nv30);
183
184 void
185 nv30_fragtex_sampler_states_bind(struct pipe_context *pipe,
186 unsigned nr, void **hwcso);
187
188 void
189 nv40_verttex_sampler_states_bind(struct pipe_context *pipe,
190 unsigned nr, void **hwcso);
191
192 void
193 nv40_verttex_set_sampler_views(struct pipe_context *pipe, unsigned nr,
194 struct pipe_sampler_view **views);
195
196 void
197 nv30_fragtex_set_sampler_views(struct pipe_context *pipe,
198 unsigned nr,
199 struct pipe_sampler_view **views);
200
201 void
202 nv30_push_vbo(struct nv30_context *nv30, const struct pipe_draw_info *info,
203 const struct pipe_draw_start_count_bias *draw);
204
205 void
206 nv30_draw_init(struct pipe_context *pipe);
207
208 void
209 nv30_render_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info,
210 unsigned drawid_offset,
211 const struct pipe_draw_start_count_bias *draw);
212
213 bool
214 nv30_state_validate(struct nv30_context *nv30, uint32_t mask, bool hwtnl);
215
216 void
217 nv30_state_release(struct nv30_context *nv30);
218
219 #ifdef NV30_3D_VERTEX_BEGIN_END
220 #define NV30_PRIM_GL_CASE(n) \
221 case MESA_PRIM_##n: return NV30_3D_VERTEX_BEGIN_END_##n
222
223 static inline unsigned
224 nv30_prim_gl(unsigned prim)
225 {
226 switch (prim) {
227 NV30_PRIM_GL_CASE(POINTS);
228 NV30_PRIM_GL_CASE(LINES);
229 NV30_PRIM_GL_CASE(LINE_LOOP);
230 NV30_PRIM_GL_CASE(LINE_STRIP);
231 NV30_PRIM_GL_CASE(TRIANGLES);
232 NV30_PRIM_GL_CASE(TRIANGLE_STRIP);
233 NV30_PRIM_GL_CASE(TRIANGLE_FAN);
234 NV30_PRIM_GL_CASE(QUADS);
235 NV30_PRIM_GL_CASE(QUAD_STRIP);
236 NV30_PRIM_GL_CASE(POLYGON);
237 default:
238 return NV30_3D_VERTEX_BEGIN_END_POINTS;
239 break;
240 }
241 }
242 #endif
243
244 #endif