Merge branch 'gallium-polygon-stipple'
[mesa.git] / src / gallium / winsys / g3dvl / dri / driclient.h
1 #ifndef driclient_h
2 #define driclient_h
3
4 #include <stdint.h>
5 #include <X11/Xmd.h>
6 #include <X11/Xlib.h>
7 #include <drm_sarea.h>
8 //#include <X11/extensions/dri2proto.h>
9 #include "xf86dri.h"
10 #include "dri2.h"
11
12 /* TODO: Bring in DRI XML options */
13
14 typedef struct dri_version
15 {
16 int major;
17 int minor;
18 int patch;
19 } dri_version_t;
20
21 typedef struct dri_screen
22 {
23 Display *display;
24 unsigned int num;
25 dri_version_t ddx, dri, drm;
26 int draw_lock_id;
27 int fd;
28 drm_sarea_t *sarea;
29 void *drawable_hash;
30 void *private;
31 } dri_screen_t;
32
33 struct dri_context;
34
35 typedef struct dri_drawable
36 {
37 drm_drawable_t drm_drawable;
38 Drawable x_drawable;
39 unsigned int sarea_index;
40 unsigned int *sarea_stamp;
41 unsigned int last_sarea_stamp;
42 int x, y, w, h;
43 int back_x, back_y;
44 int num_cliprects, num_back_cliprects;
45 drm_clip_rect_t *cliprects, *back_cliprects;
46 dri_screen_t *dri_screen;
47 unsigned int refcount;
48 void *private;
49 } dri_drawable_t;
50
51 typedef struct dri_context
52 {
53 XID id;
54 drm_context_t drm_context;
55 dri_screen_t *dri_screen;
56 void *private;
57 } dri_context_t;
58
59 typedef struct dri_framebuffer
60 {
61 drm_handle_t drm_handle;
62 int base, size, stride;
63 int private_size;
64 void *private;
65 } dri_framebuffer_t;
66
67 int driCreateScreen(Display *display, int screen, dri_screen_t **dri_screen, dri_framebuffer_t *dri_framebuf);
68 int driDestroyScreen(dri_screen_t *dri_screen);
69 int driCreateDrawable(dri_screen_t *dri_screen, Drawable drawable, dri_drawable_t **dri_drawable);
70 int driUpdateDrawableInfo(dri_drawable_t *dri_drawable);
71 int driDestroyDrawable(dri_drawable_t *dri_drawable);
72 int driCreateContext(dri_screen_t *dri_screen, Visual *visual, dri_context_t **dri_context);
73 int driDestroyContext(dri_context_t *dri_context);
74
75 #define DRI_VALIDATE_DRAWABLE_INFO_ONCE(dri_drawable) \
76 do \
77 { \
78 if (*(dri_drawable->sarea_stamp) != dri_drawable->last_sarea_stamp) \
79 driUpdateDrawableInfo(dri_drawable); \
80 } while (0)
81
82 #define DRI_VALIDATE_DRAWABLE_INFO(dri_screen, dri_drawable) \
83 do \
84 { \
85 while (*(dri_drawable->sarea_stamp) != dri_drawable->last_sarea_stamp) \
86 { \
87 register unsigned int hwContext = dri_screen->sarea->lock.lock & \
88 ~(DRM_LOCK_HELD | DRM_LOCK_CONT); \
89 DRM_UNLOCK(dri_screen->fd, &dri_screen->sarea->lock, hwContext); \
90 \
91 DRM_SPINLOCK(&dri_screen->sarea->drawable_lock, dri_screen->draw_lock_id); \
92 DRI_VALIDATE_DRAWABLE_INFO_ONCE(dri_drawable); \
93 DRM_SPINUNLOCK(&dri_screen->sarea->drawable_lock, dri_screen->draw_lock_id); \
94 \
95 DRM_LIGHT_LOCK(dri_screen->fd, &dri_screen->sarea->lock, hwContext); \
96 } \
97 } while (0)
98
99 int dri2CreateScreen(Display *display, int screen, dri_screen_t **dri_screen);
100 int dri2DestroyScreen(dri_screen_t *dri_screen);
101 int dri2CreateDrawable(dri_screen_t *dri_screen, XID drawable);
102 int dri2DestroyDrawable(dri_screen_t *dri_screen, XID drawable);
103 int dri2CopyDrawable(dri_screen_t *dri_screen, XID drawable, int dest, int src);
104
105 #define DRI_BUFFER_FRONT_LEFT 0
106 #define DRI_BUFFER_BACK_LEFT 1
107 #define DRI_BUFFER_FRONT_RIGHT 2
108 #define DRI_BUFFER_BACK_RIGHT 3
109 #define DRI_BUFFER_DEPTH 4
110 #define DRI_BUFFER_STENCIL 5
111 #define DRI_BUFFER_ACCUM 6
112 #define DRI_BUFFER_FAKE_FRONT_LEFT 7
113 #define DRI_BUFFER_FAKE_FRONT_RIGHT 8
114 #define DRI_BUFFER_DEPTH_STENCIL 9 /**< Only available with DRI2 1.1 */
115
116 #endif
117