Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / libs / mesa / src / gallium / drivers / nvc0 / nvc0_context.h
blobb05cc337d5de0b9c0e023053a3bc77c6a8a7af89
1 #ifndef __NVC0_CONTEXT_H__
2 #define __NVC0_CONTEXT_H__
4 #include "pipe/p_context.h"
5 #include "pipe/p_defines.h"
6 #include "pipe/p_state.h"
8 #include "util/u_memory.h"
9 #include "util/u_math.h"
10 #include "util/u_inlines.h"
11 #include "util/u_dynarray.h"
13 #include "draw/draw_vertex.h"
15 #include "nv50/nv50_debug.h"
16 #include "nvc0_winsys.h"
17 #include "nvc0_stateobj.h"
18 #include "nvc0_screen.h"
19 #include "nvc0_program.h"
20 #include "nvc0_resource.h"
22 #include "nouveau/nouveau_context.h"
24 #include "nvc0_3ddefs.xml.h"
25 #include "nvc0_3d.xml.h"
26 #include "nvc0_2d.xml.h"
27 #include "nvc0_m2mf.xml.h"
29 #define NVC0_NEW_BLEND (1 << 0)
30 #define NVC0_NEW_RASTERIZER (1 << 1)
31 #define NVC0_NEW_ZSA (1 << 2)
32 #define NVC0_NEW_VERTPROG (1 << 3)
33 #define NVC0_NEW_TCTLPROG (1 << 4)
34 #define NVC0_NEW_TEVLPROG (1 << 5)
35 #define NVC0_NEW_GMTYPROG (1 << 6)
36 #define NVC0_NEW_FRAGPROG (1 << 7)
37 #define NVC0_NEW_BLEND_COLOUR (1 << 8)
38 #define NVC0_NEW_STENCIL_REF (1 << 9)
39 #define NVC0_NEW_CLIP (1 << 10)
40 #define NVC0_NEW_SAMPLE_MASK (1 << 11)
41 #define NVC0_NEW_FRAMEBUFFER (1 << 12)
42 #define NVC0_NEW_STIPPLE (1 << 13)
43 #define NVC0_NEW_SCISSOR (1 << 14)
44 #define NVC0_NEW_VIEWPORT (1 << 15)
45 #define NVC0_NEW_ARRAYS (1 << 16)
46 #define NVC0_NEW_VERTEX (1 << 17)
47 #define NVC0_NEW_CONSTBUF (1 << 18)
48 #define NVC0_NEW_TEXTURES (1 << 19)
49 #define NVC0_NEW_SAMPLERS (1 << 20)
50 #define NVC0_NEW_TFB (1 << 21)
51 #define NVC0_NEW_TFB_BUFFERS (1 << 22)
53 #define NVC0_BUFCTX_CONSTANT 0
54 #define NVC0_BUFCTX_FRAME 1
55 #define NVC0_BUFCTX_VERTEX 2
56 #define NVC0_BUFCTX_TEXTURES 3
57 #define NVC0_BUFCTX_COUNT 4
59 struct nvc0_context {
60 struct nouveau_context base;
62 struct nvc0_screen *screen;
64 struct util_dynarray residents[NVC0_BUFCTX_COUNT];
65 unsigned residents_size;
67 uint32_t dirty;
69 struct {
70 uint32_t instance_elts; /* bitmask of per-instance elements */
71 uint32_t instance_base;
72 int32_t index_bias;
73 boolean prim_restart;
74 boolean early_z;
75 uint8_t num_vtxbufs;
76 uint8_t num_vtxelts;
77 uint8_t num_textures[5];
78 uint8_t num_samplers[5];
79 uint8_t tls_required; /* bitmask of shader types using l[] */
80 uint16_t scissor;
81 uint32_t uniform_buffer_bound[5];
82 } state;
84 struct nvc0_blend_stateobj *blend;
85 struct nvc0_rasterizer_stateobj *rast;
86 struct nvc0_zsa_stateobj *zsa;
87 struct nvc0_vertex_stateobj *vertex;
89 struct nvc0_program *vertprog;
90 struct nvc0_program *tctlprog;
91 struct nvc0_program *tevlprog;
92 struct nvc0_program *gmtyprog;
93 struct nvc0_program *fragprog;
95 struct pipe_resource *constbuf[5][16];
96 uint16_t constbuf_dirty[5];
98 struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
99 unsigned num_vtxbufs;
100 struct pipe_index_buffer idxbuf;
101 uint32_t vbo_fifo; /* bitmask of vertex elements to be pushed to FIFO */
102 uint32_t vbo_user; /* bitmask of vertex buffers pointing to user memory */
103 unsigned vbo_min_index; /* from pipe_draw_info, for vertex upload */
104 unsigned vbo_max_index;
106 struct pipe_sampler_view *textures[5][PIPE_MAX_SAMPLERS];
107 unsigned num_textures[5];
108 struct nv50_tsc_entry *samplers[5][PIPE_MAX_SAMPLERS];
109 unsigned num_samplers[5];
111 struct pipe_framebuffer_state framebuffer;
112 struct pipe_blend_color blend_colour;
113 struct pipe_stencil_ref stencil_ref;
114 struct pipe_poly_stipple stipple;
115 struct pipe_scissor_state scissor;
116 struct pipe_viewport_state viewport;
117 struct pipe_clip_state clip;
119 unsigned sample_mask;
121 boolean vbo_push_hint;
123 struct nvc0_transform_feedback_state *tfb;
124 struct pipe_resource *tfbbuf[4];
125 unsigned num_tfbbufs;
126 unsigned tfb_offset[4];
128 struct draw_context *draw;
131 #define NVC0_USING_EDGEFLAG(ctx) \
132 ((ctx)->vertprog->vp.edgeflag < PIPE_MAX_ATTRIBS)
134 static INLINE struct nvc0_context *
135 nvc0_context(struct pipe_context *pipe)
137 return (struct nvc0_context *)pipe;
140 struct nvc0_surface {
141 struct pipe_surface base;
142 uint32_t offset;
143 uint32_t width;
144 uint16_t height;
145 uint16_t depth;
148 static INLINE struct nvc0_surface *
149 nvc0_surface(struct pipe_surface *ps)
151 return (struct nvc0_surface *)ps;
154 /* nvc0_context.c */
155 struct pipe_context *nvc0_create(struct pipe_screen *, void *);
157 void nvc0_default_flush_notify(struct nouveau_channel *);
159 void nvc0_bufctx_emit_relocs(struct nvc0_context *);
160 void nvc0_bufctx_add_resident(struct nvc0_context *, int ctx,
161 struct nv04_resource *, uint32_t flags);
162 void nvc0_bufctx_del_resident(struct nvc0_context *, int ctx,
163 struct nv04_resource *);
164 static INLINE void
165 nvc0_bufctx_reset(struct nvc0_context *nvc0, int ctx)
167 nvc0->residents_size -= nvc0->residents[ctx].size;
168 util_dynarray_resize(&nvc0->residents[ctx], 0);
171 /* nvc0_draw.c */
172 extern struct draw_stage *nvc0_draw_render_stage(struct nvc0_context *);
174 /* nvc0_program.c */
175 boolean nvc0_program_translate(struct nvc0_program *);
176 void nvc0_program_destroy(struct nvc0_context *, struct nvc0_program *);
178 /* nvc0_query.c */
179 void nvc0_init_query_functions(struct nvc0_context *);
181 /* nvc0_shader_state.c */
182 void nvc0_vertprog_validate(struct nvc0_context *);
183 void nvc0_tctlprog_validate(struct nvc0_context *);
184 void nvc0_tevlprog_validate(struct nvc0_context *);
185 void nvc0_gmtyprog_validate(struct nvc0_context *);
186 void nvc0_fragprog_validate(struct nvc0_context *);
188 void nvc0_tfb_validate(struct nvc0_context *);
190 /* nvc0_state.c */
191 extern void nvc0_init_state_functions(struct nvc0_context *);
193 /* nvc0_state_validate.c */
194 extern boolean nvc0_state_validate(struct nvc0_context *);
196 /* nvc0_surface.c */
197 extern void nvc0_clear(struct pipe_context *, unsigned buffers,
198 const float *rgba, double depth, unsigned stencil);
199 extern void nvc0_init_surface_functions(struct nvc0_context *);
201 /* nvc0_tex.c */
202 void nvc0_validate_textures(struct nvc0_context *);
203 void nvc0_validate_samplers(struct nvc0_context *);
205 struct pipe_sampler_view *
206 nvc0_create_sampler_view(struct pipe_context *,
207 struct pipe_resource *,
208 const struct pipe_sampler_view *);
210 /* nvc0_transfer.c */
211 void
212 nvc0_m2mf_push_linear(struct nouveau_context *nv,
213 struct nouveau_bo *dst, unsigned offset, unsigned domain,
214 unsigned size, void *data);
215 void
216 nvc0_m2mf_copy_linear(struct nouveau_context *nv,
217 struct nouveau_bo *dst, unsigned dstoff, unsigned dstdom,
218 struct nouveau_bo *src, unsigned srcoff, unsigned srcdom,
219 unsigned size);
221 /* nvc0_vbo.c */
222 void nvc0_draw_vbo(struct pipe_context *, const struct pipe_draw_info *);
224 void *
225 nvc0_vertex_state_create(struct pipe_context *pipe,
226 unsigned num_elements,
227 const struct pipe_vertex_element *elements);
228 void
229 nvc0_vertex_state_delete(struct pipe_context *pipe, void *hwcso);
231 void nvc0_vertex_arrays_validate(struct nvc0_context *nvc0);
233 /* nvc0_push.c */
234 void nvc0_push_vbo(struct nvc0_context *, const struct pipe_draw_info *);
235 void nvc0_push_vbo2(struct nvc0_context *, const struct pipe_draw_info *);
237 #endif