1 #ifndef __NV50_CONTEXT_H__
2 #define __NV50_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_debug.h"
16 #include "nv50_winsys.h"
17 #include "nv50_stateobj.h"
18 #include "nv50_screen.h"
19 #include "nv50_program.h"
20 #include "nv50_resource.h"
21 #include "nv50_transfer.h"
23 #include "nouveau/nouveau_context.h"
24 #include "nouveau/nv_object.xml.h"
25 #include "nouveau/nv_m2mf.xml.h"
26 #include "nv50_3ddefs.xml.h"
27 #include "nv50_3d.xml.h"
28 #include "nv50_2d.xml.h"
30 #define NV50_NEW_BLEND (1 << 0)
31 #define NV50_NEW_RASTERIZER (1 << 1)
32 #define NV50_NEW_ZSA (1 << 2)
33 #define NV50_NEW_VERTPROG (1 << 3)
34 #define NV50_NEW_GMTYPROG (1 << 6)
35 #define NV50_NEW_FRAGPROG (1 << 7)
36 #define NV50_NEW_BLEND_COLOUR (1 << 8)
37 #define NV50_NEW_STENCIL_REF (1 << 9)
38 #define NV50_NEW_CLIP (1 << 10)
39 #define NV50_NEW_SAMPLE_MASK (1 << 11)
40 #define NV50_NEW_FRAMEBUFFER (1 << 12)
41 #define NV50_NEW_STIPPLE (1 << 13)
42 #define NV50_NEW_SCISSOR (1 << 14)
43 #define NV50_NEW_VIEWPORT (1 << 15)
44 #define NV50_NEW_ARRAYS (1 << 16)
45 #define NV50_NEW_VERTEX (1 << 17)
46 #define NV50_NEW_CONSTBUF (1 << 18)
47 #define NV50_NEW_TEXTURES (1 << 19)
48 #define NV50_NEW_SAMPLERS (1 << 20)
49 #define NV50_NEW_CONTEXT (1 << 31)
51 #define NV50_BIND_FB 0
52 #define NV50_BIND_VERTEX 1
53 #define NV50_BIND_VERTEX_TMP 2
54 #define NV50_BIND_INDEX 3
55 #define NV50_BIND_TEXTURES 4
56 #define NV50_BIND_CB(s, i) (5 + 16 * (s) + (i))
57 #define NV50_BIND_SCREEN 53
58 #define NV50_BIND_TLS 54
59 #define NV50_BIND_COUNT 55
60 #define NV50_BIND_2D 0
61 #define NV50_BIND_M2MF 0
62 #define NV50_BIND_FENCE 1
64 #define NV50_CB_TMP 123
65 /* fixed constant buffer binding points - low indices for user's constbufs */
66 #define NV50_CB_PVP 124
67 #define NV50_CB_PGP 126
68 #define NV50_CB_PFP 125
69 #define NV50_CB_AUX 127
73 struct nouveau_context base
;
75 struct nv50_screen
*screen
;
77 struct nouveau_bufctx
*bufctx_3d
;
78 struct nouveau_bufctx
*bufctx
;
83 uint32_t instance_elts
; /* bitmask of per-instance elements */
84 uint32_t instance_base
;
85 uint32_t interpolant_ctrl
;
86 uint32_t semantic_color
;
87 uint32_t semantic_psize
;
96 uint8_t num_textures
[3];
97 uint8_t num_samplers
[3];
101 struct nv50_blend_stateobj
*blend
;
102 struct nv50_rasterizer_stateobj
*rast
;
103 struct nv50_zsa_stateobj
*zsa
;
104 struct nv50_vertex_stateobj
*vertex
;
106 struct nv50_program
*vertprog
;
107 struct nv50_program
*gmtyprog
;
108 struct nv50_program
*fragprog
;
110 struct pipe_resource
*constbuf
[3][16];
111 uint16_t constbuf_dirty
[3];
112 uint16_t constbuf_valid
[3];
114 struct pipe_vertex_buffer vtxbuf
[PIPE_MAX_ATTRIBS
];
115 unsigned num_vtxbufs
;
116 struct pipe_index_buffer idxbuf
;
117 uint32_t vbo_fifo
; /* bitmask of vertex elements to be pushed to FIFO */
118 uint32_t vbo_user
; /* bitmask of vertex buffers pointing to user memory */
119 uint32_t vb_elt_first
; /* from pipe_draw_info, for vertex upload */
120 uint32_t vb_elt_limit
; /* max - min element (count - 1) */
122 struct pipe_sampler_view
*textures
[3][PIPE_MAX_SAMPLERS
];
123 unsigned num_textures
[3];
124 struct nv50_tsc_entry
*samplers
[3][PIPE_MAX_SAMPLERS
];
125 unsigned num_samplers
[3];
127 struct pipe_framebuffer_state framebuffer
;
128 struct pipe_blend_color blend_colour
;
129 struct pipe_stencil_ref stencil_ref
;
130 struct pipe_poly_stipple stipple
;
131 struct pipe_scissor_state scissor
;
132 struct pipe_viewport_state viewport
;
133 struct pipe_clip_state clip
;
135 unsigned sample_mask
;
137 boolean vbo_push_hint
;
139 struct draw_context
*draw
;
142 static INLINE
struct nv50_context
*
143 nv50_context(struct pipe_context
*pipe
)
145 return (struct nv50_context
*)pipe
;
148 static INLINE
struct nv50_screen
*
149 nv50_context_screen(struct nv50_context
*nv50
)
151 return nv50_screen(&nv50
->base
.screen
->base
);
156 struct pipe_context
*nv50_create(struct pipe_screen
*, void *);
158 void nv50_bufctx_fence(struct nouveau_bufctx
*, boolean on_flush
);
160 void nv50_default_kick_notify(struct nouveau_pushbuf
*);
163 extern struct draw_stage
*nv50_draw_render_stage(struct nv50_context
*);
166 void nv50_init_query_functions(struct nv50_context
*);
168 /* nv50_shader_state.c */
169 void nv50_vertprog_validate(struct nv50_context
*);
170 void nv50_gmtyprog_validate(struct nv50_context
*);
171 void nv50_fragprog_validate(struct nv50_context
*);
172 void nv50_fp_linkage_validate(struct nv50_context
*);
173 void nv50_gp_linkage_validate(struct nv50_context
*);
174 void nv50_constbufs_validate(struct nv50_context
*);
175 void nv50_validate_derived_rs(struct nv50_context
*);
178 extern void nv50_init_state_functions(struct nv50_context
*);
180 /* nv50_state_validate.c */
181 /* @words: check for space before emitting relocs */
182 extern boolean
nv50_state_validate(struct nv50_context
*, uint32_t state_mask
,
183 unsigned space_words
);
186 extern void nv50_clear(struct pipe_context
*, unsigned buffers
,
187 const union pipe_color_union
*color
,
188 double depth
, unsigned stencil
);
189 extern void nv50_init_surface_functions(struct nv50_context
*);
192 void nv50_validate_textures(struct nv50_context
*);
193 void nv50_validate_samplers(struct nv50_context
*);
195 struct pipe_sampler_view
*
196 nv50_create_sampler_view(struct pipe_context
*,
197 struct pipe_resource
*,
198 const struct pipe_sampler_view
*);
200 /* nv50_transfer.c */
202 nv50_m2mf_transfer_rect(struct nv50_context
*,
203 const struct nv50_m2mf_rect
*dst
,
204 const struct nv50_m2mf_rect
*src
,
205 uint32_t nblocksx
, uint32_t nblocksy
);
207 nv50_sifc_linear_u8(struct nouveau_context
*pipe
,
208 struct nouveau_bo
*dst
, unsigned offset
, unsigned domain
,
209 unsigned size
, const void *data
);
211 nv50_m2mf_copy_linear(struct nouveau_context
*pipe
,
212 struct nouveau_bo
*dst
, unsigned dstoff
, unsigned dstdom
,
213 struct nouveau_bo
*src
, unsigned srcoff
, unsigned srcdom
,
216 nv50_cb_push(struct nouveau_context
*nv
,
217 struct nouveau_bo
*bo
, unsigned domain
,
218 unsigned base
, unsigned size
,
219 unsigned offset
, unsigned words
, const uint32_t *data
);
222 void nv50_draw_vbo(struct pipe_context
*, const struct pipe_draw_info
*);
225 nv50_vertex_state_create(struct pipe_context
*pipe
,
226 unsigned num_elements
,
227 const struct pipe_vertex_element
*elements
);
229 nv50_vertex_state_delete(struct pipe_context
*pipe
, void *hwcso
);
231 void nv50_vertex_arrays_validate(struct nv50_context
*nv50
);
234 void nv50_push_vbo(struct nv50_context
*, const struct pipe_draw_info
*);