16
16
#include "nouveau/nouveau_winsys.h"
17
17
#include "nouveau/nouveau_gldefs.h"
18
18
#include "nouveau/nouveau_stateobj.h"
19
#include "nouveau/nouveau_context.h"
21
21
#include "nv50_screen.h"
22
22
#include "nv50_program.h"
24
24
#define NOUVEAU_ERR(fmt, args...) \
25
fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args);
25
fprintf(stderr, "%s:%d - "fmt, __FUNCTION__, __LINE__, ##args);
26
26
#define NOUVEAU_MSG(fmt, args...) \
27
27
fprintf(stderr, "nouveau: "fmt, ##args);
117
116
struct nv50_state {
117
struct nouveau_stateobj *hw[64];
120
struct nouveau_stateobj *fb;
121
struct nouveau_stateobj *blend;
122
struct nouveau_stateobj *blend_colour;
123
struct nouveau_stateobj *zsa;
124
struct nouveau_stateobj *stencil_ref;
125
struct nouveau_stateobj *rast;
126
struct nouveau_stateobj *stipple;
127
struct nouveau_stateobj *scissor;
128
unsigned scissor_enabled;
129
struct nouveau_stateobj *viewport;
130
struct nouveau_stateobj *tsc_upload;
131
struct nouveau_stateobj *tic_upload;
132
unsigned miptree_nr[PIPE_SHADER_TYPES];
133
struct nouveau_stateobj *vertprog;
134
struct nouveau_stateobj *fragprog;
135
struct nouveau_stateobj *geomprog;
136
struct nouveau_stateobj *fp_linkage;
137
struct nouveau_stateobj *gp_linkage;
138
struct nouveau_stateobj *vtxfmt;
120
unsigned sampler_view_nr[3];
139
121
struct nouveau_stateobj *vtxbuf;
140
122
struct nouveau_stateobj *vtxattr;
141
struct nouveau_stateobj *instbuf;
142
123
unsigned vtxelt_nr;
161
142
struct pipe_scissor_state scissor;
162
143
struct pipe_viewport_state viewport;
163
144
struct pipe_framebuffer_state framebuffer;
145
struct pipe_clip_state clip;
164
146
struct nv50_program *vertprog;
165
147
struct nv50_program *fragprog;
166
148
struct nv50_program *geomprog;
167
struct pipe_buffer *constbuf[PIPE_SHADER_TYPES];
149
struct pipe_resource *constbuf[PIPE_SHADER_TYPES];
168
150
struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
169
151
unsigned vtxbuf_nr;
170
struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS];
172
struct nv50_sampler_stateobj *sampler[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
173
unsigned sampler_nr[PIPE_SHADER_TYPES];
174
struct nv50_miptree *miptree[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
175
unsigned miptree_nr[PIPE_SHADER_TYPES];
152
struct pipe_index_buffer idxbuf;
153
struct nv50_vtxelt_stateobj *vtxelt;
154
struct nv50_sampler_stateobj *sampler[3][PIPE_MAX_SAMPLERS];
155
unsigned sampler_nr[3];
156
struct pipe_sampler_view *sampler_views[3][PIPE_MAX_SAMPLERS];
157
unsigned sampler_view_nr[3];
180
162
static INLINE struct nv50_context *
198
181
extern struct draw_stage *nv50_draw_render_stage(struct nv50_context *nv50);
201
extern void nv50_draw_arrays(struct pipe_context *, unsigned mode,
202
unsigned start, unsigned count);
203
extern void nv50_draw_arrays_instanced(struct pipe_context *, unsigned mode,
204
unsigned start, unsigned count,
205
unsigned startInstance,
206
unsigned instanceCount);
207
extern void nv50_draw_elements(struct pipe_context *pipe,
208
struct pipe_buffer *indexBuffer,
210
unsigned mode, unsigned start,
212
extern void nv50_draw_elements_instanced(struct pipe_context *pipe,
213
struct pipe_buffer *indexBuffer,
215
unsigned mode, unsigned start,
217
unsigned startInstance,
218
unsigned instanceCount);
219
extern void nv50_vbo_validate(struct nv50_context *nv50);
184
extern void nv50_draw_vbo(struct pipe_context *pipe,
185
const struct pipe_draw_info *info);
186
extern void nv50_vtxelt_construct(struct nv50_vtxelt_stateobj *cso);
187
extern struct nouveau_stateobj *nv50_vbo_validate(struct nv50_context *nv50);
191
nv50_push_elements_instanced(struct pipe_context *, struct pipe_resource *,
192
unsigned idxsize, int idxbias,
193
unsigned mode, unsigned start,
194
unsigned count, unsigned i_start,
221
197
/* nv50_clear.c */
222
198
extern void nv50_clear(struct pipe_context *pipe, unsigned buffers,
223
199
const float *rgba, double depth, unsigned stencil);
225
201
/* nv50_program.c */
226
extern void nv50_vertprog_validate(struct nv50_context *nv50);
227
extern void nv50_fragprog_validate(struct nv50_context *nv50);
228
extern void nv50_geomprog_validate(struct nv50_context *nv50);
229
extern void nv50_fp_linkage_validate(struct nv50_context *nv50);
230
extern void nv50_gp_linkage_validate(struct nv50_context *nv50);
202
extern struct nouveau_stateobj *
203
nv50_vertprog_validate(struct nv50_context *nv50);
204
extern struct nouveau_stateobj *
205
nv50_fragprog_validate(struct nv50_context *nv50);
206
extern struct nouveau_stateobj *
207
nv50_geomprog_validate(struct nv50_context *nv50);
208
extern struct nouveau_stateobj *
209
nv50_fp_linkage_validate(struct nv50_context *nv50);
210
extern struct nouveau_stateobj *
211
nv50_gp_linkage_validate(struct nv50_context *nv50);
231
212
extern void nv50_program_destroy(struct nv50_context *nv50,
232
213
struct nv50_program *p);
234
215
/* nv50_state_validate.c */
235
extern boolean nv50_state_validate(struct nv50_context *nv50);
236
extern void nv50_state_flush_notify(struct nouveau_channel *chan);
216
extern boolean nv50_state_validate(struct nv50_context *nv50, unsigned dwords);
238
218
extern void nv50_so_init_sifc(struct nv50_context *nv50,
239
219
struct nouveau_stateobj *so,
241
221
unsigned offset, unsigned size);
244
extern void nv50_tex_validate(struct nv50_context *);
224
extern boolean nv50_tex_construct(struct nv50_sampler_view *view);
225
extern void nv50_tex_relocs(struct nv50_context *);
226
extern struct nouveau_stateobj *nv50_tex_validate(struct nv50_context *);
246
/* nv50_transfer.c */
248
nv50_upload_sifc(struct nv50_context *nv50,
249
struct nouveau_bo *bo, unsigned dst_offset, unsigned reloc,
250
unsigned dst_format, int dst_w, int dst_h, int dst_pitch,
251
void *src, unsigned src_format, int src_pitch,
252
int x, int y, int w, int h, int cpp);
254
229
/* nv50_context.c */
255
230
struct pipe_context *
256
231
nv50_create(struct pipe_screen *pscreen, void *priv);
233
static INLINE unsigned
234
nv50_prim(unsigned mode)
237
case PIPE_PRIM_POINTS: return NV50TCL_VERTEX_BEGIN_POINTS;
238
case PIPE_PRIM_LINES: return NV50TCL_VERTEX_BEGIN_LINES;
239
case PIPE_PRIM_LINE_LOOP: return NV50TCL_VERTEX_BEGIN_LINE_LOOP;
240
case PIPE_PRIM_LINE_STRIP: return NV50TCL_VERTEX_BEGIN_LINE_STRIP;
241
case PIPE_PRIM_TRIANGLES: return NV50TCL_VERTEX_BEGIN_TRIANGLES;
242
case PIPE_PRIM_TRIANGLE_STRIP:
243
return NV50TCL_VERTEX_BEGIN_TRIANGLE_STRIP;
244
case PIPE_PRIM_TRIANGLE_FAN: return NV50TCL_VERTEX_BEGIN_TRIANGLE_FAN;
245
case PIPE_PRIM_QUADS: return NV50TCL_VERTEX_BEGIN_QUADS;
246
case PIPE_PRIM_QUAD_STRIP: return NV50TCL_VERTEX_BEGIN_QUAD_STRIP;
247
case PIPE_PRIM_POLYGON: return NV50TCL_VERTEX_BEGIN_POLYGON;
248
case PIPE_PRIM_LINES_ADJACENCY:
249
return NV50TCL_VERTEX_BEGIN_LINES_ADJACENCY;
250
case PIPE_PRIM_LINE_STRIP_ADJACENCY:
251
return NV50TCL_VERTEX_BEGIN_LINE_STRIP_ADJACENCY;
252
case PIPE_PRIM_TRIANGLES_ADJACENCY:
253
return NV50TCL_VERTEX_BEGIN_TRIANGLES_ADJACENCY;
254
case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
255
return NV50TCL_VERTEX_BEGIN_TRIANGLE_STRIP_ADJACENCY;
260
NOUVEAU_ERR("invalid primitive type %d\n", mode);
261
return NV50TCL_VERTEX_BEGIN_POINTS;