6 #include "egl_tracker.h"
11 #include "pipe/p_context.h"
12 #include "pipe/p_screen.h"
14 #include "state_tracker/st_public.h"
15 #include "state_tracker/drm_api.h"
17 #include "GL/internal/glcore.h"
20 drm_create_context(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLConfig
*conf
, _EGLContext
*share_list
, const EGLint
*attrib_list
)
22 struct drm_device
*dev
= lookup_drm_device(dpy
);
23 struct drm_context
*ctx
;
24 struct drm_context
*share
= NULL
;
25 struct st_context
*st_share
= NULL
;
27 __GLcontextModes
*visual
;
29 for (i
= 0; attrib_list
&& attrib_list
[i
] != EGL_NONE
; i
++) {
30 switch (attrib_list
[i
]) {
31 /* no attribs defined for now */
33 _eglError(EGL_BAD_ATTRIBUTE
, "eglCreateContext");
34 return EGL_NO_CONTEXT
;
38 ctx
= (struct drm_context
*) calloc(1, sizeof(struct drm_context
));
42 _eglInitContext(drv
, &ctx
->base
, conf
, attrib_list
);
44 ctx
->pipe
= dev
->api
->create_context(dev
->api
, dev
->screen
);
51 visual
= drm_visual_from_config(conf
);
52 ctx
->st
= st_create_context(ctx
->pipe
, visual
, st_share
);
53 drm_visual_modes_destroy(visual
);
61 ctx
->pipe
->destroy(ctx
->pipe
);
69 drm_destroy_context(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLContext
*context
)
71 struct drm_context
*c
= lookup_drm_context(context
);
72 if (!_eglIsContextBound(&c
->base
)) {
73 st_destroy_context(c
->st
);
80 drm_make_current(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLSurface
*draw
, _EGLSurface
*read
, _EGLContext
*context
)
82 struct drm_surface
*readSurf
= lookup_drm_surface(read
);
83 struct drm_surface
*drawSurf
= lookup_drm_surface(draw
);
84 struct drm_context
*ctx
= lookup_drm_context(context
);
87 b
= _eglMakeCurrent(drv
, dpy
, draw
, read
, context
);
92 if (!drawSurf
|| !readSurf
)
95 st_make_current(ctx
->st
, drawSurf
->stfb
, readSurf
->stfb
);
97 /* st_resize_framebuffer needs a bound context to work */
98 st_resize_framebuffer(drawSurf
->stfb
, drawSurf
->w
, drawSurf
->h
);
99 st_resize_framebuffer(readSurf
->stfb
, readSurf
->w
, readSurf
->h
);
101 st_make_current(NULL
, NULL
, NULL
);