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