1 #include "nouveau_context_vl.h"
2 #include <pipe/p_defines.h>
3 #include <pipe/p_context.h>
4 #include <pipe/p_screen.h>
5 #include <util/u_memory.h>
6 #include <common/nouveau_dri.h>
7 #include <common/nouveau_local.h>
8 #include <common/nouveau_winsys_pipe.h>
9 #include "nouveau_screen_vl.h"
13 static const struct dri_debug_control debug_control[] = {
17 int __nouveau_debug = 0;
22 nouveau_context_create(dri_context_t *dri_context)
24 dri_screen_t *dri_screen;
25 struct nouveau_screen_vl *nv_screen;
26 struct nouveau_context_vl *nv;
30 dri_screen = dri_context->dri_screen;
31 nv_screen = dri_screen->private;
32 nv = CALLOC_STRUCT(nouveau_context_vl);
37 if (nouveau_context_init(&nv_screen->base, dri_context->drm_context,
38 (drmLock*)&dri_screen->sarea->lock, NULL, &nv->base))
44 dri_context->private = (void*)nv;
45 nv->dri_context = dri_context;
46 nv->nv_screen = nv_screen;
49 driParseConfigFiles(&nv->dri_option_cache, &nv_screen->option_cache,
50 nv->dri_screen->myNum, "nouveau");
52 __nouveau_debug = driParseDebugString(getenv("NOUVEAU_DEBUG"),
57 nv->base.nvc->pctx[nv->base.pctx_id]->priv = nv;
63 nouveau_context_destroy(dri_context_t *dri_context)
65 struct nouveau_context_vl *nv = dri_context->private;
69 nouveau_context_cleanup(&nv->base);
75 nouveau_context_bind(struct nouveau_context_vl *nv, dri_drawable_t *dri_drawable)
80 if (nv->dri_drawable != dri_drawable)
82 nv->dri_drawable = dri_drawable;
83 dri_drawable->private = nv;
90 nouveau_context_unbind(struct nouveau_context_vl *nv)
94 nv->dri_drawable = NULL;
99 /* Show starts here */
101 int bind_pipe_drawable(struct pipe_context *pipe, Drawable drawable)
103 struct nouveau_context_vl *nv;
104 dri_drawable_t *dri_drawable;
110 driCreateDrawable(nv->nv_screen->dri_screen, drawable, &dri_drawable);
112 nouveau_context_bind(nv, dri_drawable);
117 int unbind_pipe_drawable(struct pipe_context *pipe)
121 nouveau_context_unbind(pipe->priv);
126 struct pipe_context* create_pipe_context(Display *display, int screen)
128 dri_screen_t *dri_screen;
129 dri_framebuffer_t dri_framebuf;
130 dri_context_t *dri_context;
131 struct nouveau_context_vl *nv;
135 driCreateScreen(display, screen, &dri_screen, &dri_framebuf);
136 driCreateContext(dri_screen, XDefaultVisual(display, screen), &dri_context);
138 nouveau_screen_create(dri_screen, &dri_framebuf);
139 nouveau_context_create(dri_context);
141 nv = dri_context->private;
143 return nv->base.nvc->pctx[nv->base.pctx_id];
146 int destroy_pipe_context(struct pipe_context *pipe)
148 struct pipe_screen *screen;
149 struct pipe_winsys *winsys;
150 struct nouveau_context_vl *nv;
151 dri_screen_t *dri_screen;
152 dri_context_t *dri_context;
156 screen = pipe->screen;
157 winsys = pipe->winsys;
159 dri_context = nv->dri_context;
160 dri_screen = dri_context->dri_screen;
163 screen->destroy(screen);
166 nouveau_context_destroy(dri_context);
167 nouveau_screen_destroy(dri_screen);
168 driDestroyContext(dri_context);
169 driDestroyScreen(dri_screen);