g3dvl: Use Gallium thread wrappers.
[mesa.git] / src / gallium / winsys / g3dvl / nouveau / nouveau_context.h
1 #ifndef __NOUVEAU_CONTEXT_H__
2 #define __NOUVEAU_CONTEXT_H__
3
4 /*#include "xmlconfig.h"*/
5
6 #include <driclient.h>
7 #include "nouveau/nouveau_winsys.h"
8 #include "nouveau_drmif.h"
9 #include "nouveau_dma.h"
10
11 struct nouveau_channel_context {
12 struct pipe_screen *pscreen;
13 int refcount;
14
15 unsigned cur_pctx;
16 unsigned nr_pctx;
17 struct pipe_context **pctx;
18
19 struct nouveau_channel *channel;
20
21 struct nouveau_notifier *sync_notifier;
22
23 /* Common */
24 struct nouveau_grobj *NvM2MF;
25 /* NV04-NV40 */
26 struct nouveau_grobj *NvCtxSurf2D;
27 struct nouveau_grobj *NvSwzSurf;
28 struct nouveau_grobj *NvImageBlit;
29 struct nouveau_grobj *NvGdiRect;
30 struct nouveau_grobj *NvSIFM;
31 /* G80 */
32 struct nouveau_grobj *Nv2D;
33
34 uint32_t next_handle;
35 uint32_t next_subchannel;
36 uint32_t next_sequence;
37 };
38
39 struct nouveau_context {
40 /* DRI stuff */
41 dri_context_t *dri_context;
42 dri_drawable_t *dri_drawable;
43 unsigned int last_stamp;
44 /*driOptionCache dri_option_cache;*/
45 drm_context_t drm_context;
46 drmLock drm_lock;
47 int locked;
48 struct nouveau_screen *nv_screen;
49 struct pipe_surface *frontbuffer;
50
51 struct {
52 int hw_vertex_buffer;
53 int hw_index_buffer;
54 } cap;
55
56 /* Hardware context */
57 struct nouveau_channel_context *nvc;
58 int pctx_id;
59
60 /* pipe_surface accel */
61 struct pipe_surface *surf_src, *surf_dst;
62 unsigned surf_src_offset, surf_dst_offset;
63
64 int (*surface_copy_prep)(struct nouveau_context *,
65 struct pipe_surface *dst,
66 struct pipe_surface *src);
67 void (*surface_copy)(struct nouveau_context *, unsigned dx, unsigned dy,
68 unsigned sx, unsigned sy, unsigned w, unsigned h);
69 void (*surface_copy_done)(struct nouveau_context *);
70 int (*surface_fill)(struct nouveau_context *, struct pipe_surface *,
71 unsigned, unsigned, unsigned, unsigned, unsigned);
72 };
73
74 extern int nouveau_context_create(dri_context_t *);
75 extern void nouveau_context_destroy(dri_context_t *);
76 extern int nouveau_context_bind(struct nouveau_context *, dri_drawable_t *);
77 extern int nouveau_context_unbind(struct nouveau_context *);
78
79 #ifdef DEBUG
80 extern int __nouveau_debug;
81
82 #define DEBUG_BO (1 << 0)
83
84 #define DBG(flag, ...) do { \
85 if (__nouveau_debug & (DEBUG_##flag)) \
86 NOUVEAU_ERR(__VA_ARGS__); \
87 } while(0)
88 #else
89 #define DBG(flag, ...)
90 #endif
91
92 extern void LOCK_HARDWARE(struct nouveau_context *);
93 extern void UNLOCK_HARDWARE(struct nouveau_context *);
94
95 extern int
96 nouveau_surface_channel_create_nv04(struct nouveau_channel_context *);
97 extern int
98 nouveau_surface_channel_create_nv50(struct nouveau_channel_context *);
99 extern int nouveau_surface_init_nv04(struct nouveau_context *);
100 extern int nouveau_surface_init_nv50(struct nouveau_context *);
101
102 extern uint32_t *nouveau_pipe_dma_beginp(struct nouveau_grobj *, int, int);
103 extern void nouveau_pipe_dma_kickoff(struct nouveau_channel *);
104
105 #endif