Ejemplo n.º 1
0
/**
 * Called by eglCreateContext via drv->API.CreateContext().
 */
static EGLContext
_eglDRICreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
                     EGLContext share_list, const EGLint *attrib_list)
{
   driDisplay *disp = Lookup_driDisplay(dpy);
   driContext *c, *share;
   void *sharePriv;
   _EGLConfig *conf;
   __GLcontextModes visMode;

   c = (driContext *) calloc(1, sizeof(*c));
   if (!c)
      return EGL_NO_CONTEXT;

   if (!_eglInitContext(drv, dpy, &c->Base, config, attrib_list)) {
      free(c);
      return EGL_NO_CONTEXT;
   }

   if (share_list != EGL_NO_CONTEXT) {
      _EGLContext *shareCtx = _eglLookupContext(share_list);
      if (!shareCtx) {
         _eglError(EGL_BAD_CONTEXT, "eglCreateContext(share_list)");
         return EGL_FALSE;
      }
   }
   share = Lookup_driContext(share_list);
   if (share)
      sharePriv = share->driContext.private;
   else
Ejemplo n.º 2
0
_EGLContext*
haiku_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
	_EGLContext *share_list, const EGLint *attrib_list)
{
	_eglLog(_EGL_DEBUG,"Creating context");
	struct haiku_egl_context* context;
	context=(struct haiku_egl_context*)calloc(1,sizeof (*context));
	if(!_eglInitContext(&context->ctx, disp, conf, attrib_list))
		printf("ERROR creating context");
	_eglLog(_EGL_DEBUG, "Context created");
	return &context->ctx;
}
Ejemplo n.º 3
0
/**
 * Called via eglCreateContext(), drv->API.CreateContext().
 */
static _EGLContext *
xdri_eglCreateContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
                      _EGLContext *share_list, const EGLint *attrib_list)
{
   struct xdri_egl_display *xdri_dpy = lookup_display(dpy);
   struct xdri_egl_config *xdri_config = lookup_config(conf);
   struct xdri_egl_context *shared = lookup_context(share_list);
   __GLXscreenConfigs *psc = xdri_dpy->psc;
   int renderType = GLX_RGBA_BIT;
   struct xdri_egl_context *xdri_ctx;

   xdri_ctx = CALLOC_STRUCT(xdri_egl_context);
   if (!xdri_ctx) {
      _eglError(EGL_BAD_ALLOC, "eglCreateContext");
      return NULL;
   }

   xdri_ctx->dummy_gc = CALLOC_STRUCT(__GLXcontextRec);
   if (!xdri_ctx->dummy_gc) {
      _eglError(EGL_BAD_ALLOC, "eglCreateContext");
      free(xdri_ctx);
      return NULL;
   }

   if (!_eglInitContext(drv, &xdri_ctx->Base, &xdri_config->Base, attrib_list)) {
      free(xdri_ctx->dummy_gc);
      free(xdri_ctx);
      return NULL;
   }

   /* the config decides the render buffer for the context */
   xdri_ctx->Base.WindowRenderBuffer = xdri_config->window_render_buffer;

   xdri_ctx->driContext =
      psc->driScreen->createContext(psc,
                                    xdri_config->mode,
                                    xdri_ctx->dummy_gc,
                                    (shared) ? shared->dummy_gc : NULL,
                                    renderType);
   if (!xdri_ctx->driContext) {
      free(xdri_ctx->dummy_gc);
      free(xdri_ctx);
      return NULL;
   }

   /* fill in the required field */
   xdri_ctx->dummy_gc->driContext = xdri_ctx->driContext;

   return &xdri_ctx->Base;
}
Ejemplo n.º 4
0
/**
 * Called via eglCreateContext(), drv->API.CreateContext().
 */
static EGLContext
xlib_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
                      EGLContext share_list, const EGLint *attrib_list)
{
   struct xlib_egl_driver *xdrv = xlib_egl_driver(drv);
   _EGLConfig *conf = _eglLookupConfig(drv, dpy, config);
   struct xlib_egl_context *ctx;
   struct st_context *share_ctx = NULL; /* XXX fix */
   __GLcontextModes visual;

   ctx = CALLOC_STRUCT(xlib_egl_context);
   if (!ctx)
      return EGL_NO_CONTEXT;

   /* let EGL lib init the common stuff */
   if (!_eglInitContext(drv, dpy, &ctx->Base, config, attrib_list)) {
      free(ctx);
      return EGL_NO_CONTEXT;
   }

   /* API-dependent context creation */
   switch (ctx->Base.ClientAPI) {
   case EGL_OPENVG_API:
   case EGL_OPENGL_ES_API:
      _eglLog(_EGL_DEBUG, "Create Context for ES version %d\n",
              ctx->Base.ClientVersion);
      /* fall-through */
   case EGL_OPENGL_API:
      /* create a softpipe context */
      ctx->pipe = softpipe_create(xdrv->screen, xdrv->winsys, NULL);
      /* Now do xlib / state tracker inits here */
      _eglConfigToContextModesRec(conf, &visual);
      ctx->Context = st_create_context(ctx->pipe, &visual, share_ctx);
      break;
   default:
      _eglError(EGL_BAD_MATCH, "eglCreateContext(unsupported API)");
      free(ctx);
      return EGL_NO_CONTEXT;
   }

   _eglSaveContext(&ctx->Base);

   return _eglGetContextHandle(&ctx->Base);
}
static _EGLContext *
egl_g3d_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
                       _EGLContext *share, const EGLint *attribs)
{
   struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
   struct egl_g3d_context *gshare = egl_g3d_context(share);
   struct egl_g3d_config *gconf = egl_g3d_config(conf);
   struct egl_g3d_context *gctx;
   struct st_context_attribs stattribs;
   enum st_context_error ctx_err = 0;

   gctx = CALLOC_STRUCT(egl_g3d_context);
   if (!gctx) {
      _eglError(EGL_BAD_ALLOC, "eglCreateContext");
      return NULL;
   }

   if (!_eglInitContext(&gctx->base, dpy, conf, attribs)) {
      FREE(gctx);
      return NULL;
   }

   memset(&stattribs, 0, sizeof(stattribs));
   if (gconf)
      stattribs.visual = gconf->stvis;

   gctx->stapi = egl_g3d_choose_st(drv, &gctx->base, &stattribs.profile);
   if (!gctx->stapi) {
      FREE(gctx);
      return NULL;
   }

   gctx->stctxi = gctx->stapi->create_context(gctx->stapi, gdpy->smapi, 
         &stattribs, &ctx_err, (gshare) ? gshare->stctxi : NULL);
   if (!gctx->stctxi) {
      FREE(gctx);
      return NULL;
   }

   gctx->stctxi->st_manager_private = (void *) &gctx->base;

   return &gctx->base;
}
Ejemplo n.º 6
0
/**
 * Just a placeholder/demo function.  Real driver will never use this!
 */
_EGLContext *
_eglCreateContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
                  _EGLContext *share_list, const EGLint *attrib_list)
{
#if 0 /* example code */
   _EGLContext *context;

   context = (_EGLContext *) calloc(1, sizeof(_EGLContext));
   if (!context)
      return NULL;

   if (!_eglInitContext(drv, context, conf, attrib_list)) {
      free(context);
      return NULL;
   }

   return context;
#endif
   return NULL;
}
/**
 * Just a placeholder/demo function.  Real driver will never use this!
 */
EGLContext
_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
                  EGLContext share_list, const EGLint *attrib_list)
{
#if 0 /* example code */
   _EGLContext *context;

   context = (_EGLContext *) calloc(1, sizeof(_EGLContext));
   if (!context)
      return EGL_NO_CONTEXT;

   if (!_eglInitContext(drv, dpy, context, config, attrib_list)) {
      free(context);
      return EGL_NO_CONTEXT;
   }

   _eglSaveContext(context);
   return context->Handle;
#endif
   return EGL_NO_CONTEXT;
}
Ejemplo n.º 8
0
_EGLContext*
haiku_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
	_EGLContext *share_list, const EGLint *attrib_list)
{
	CALLED();

	struct haiku_egl_context* context;
	context = (struct haiku_egl_context*) calloc(1, sizeof (*context));
	if (!context) {
		_eglError(EGL_BAD_ALLOC, "haiku_create_context");
		return NULL;
	}

	if (!_eglInitContext(&context->ctx, disp, conf, attrib_list))
		goto cleanup;

	TRACE("Context created\n");
	return &context->ctx;

cleanup:
	free(context);
	return NULL;
}
Ejemplo n.º 9
0
static EGLContext
fbCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list)
{
   GLcontext *ctx;
   _EGLConfig *conf;
   fbContext *c;
   _EGLDisplay *disp = _eglLookupDisplay(dpy);
   struct dd_function_table functions;
   GLvisual vis;
   int i;

   conf = _eglLookupConfig(drv, dpy, config);
   if (!conf) {
      _eglError(EGL_BAD_CONFIG, "eglCreateContext");
      return EGL_NO_CONTEXT;
   }

   for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) {
      switch (attrib_list[i]) {
         /* no attribs defined for now */
      default:
         _eglError(EGL_BAD_ATTRIBUTE, "eglCreateContext");
         return EGL_NO_CONTEXT;
      }
   }

   c = (fbContext *) calloc(1, sizeof(fbContext));
   if (!c)
      return EGL_NO_CONTEXT;

   _eglInitContext(&c->Base);
   c->Base.Display = disp;
   c->Base.Config = conf;
   c->Base.DrawSurface = EGL_NO_SURFACE;
   c->Base.ReadSurface = EGL_NO_SURFACE;

   /* generate handle and insert into hash table */
   _eglSaveContext(&c->Base);
   assert(c->Base.Handle);

   /* Init default driver functions then plug in our FBdev-specific functions
    */
   _mesa_init_driver_functions(&functions);
   init_core_functions(&functions);

   _eglConfigToContextModesRec(conf, &vis);

   ctx = c->glCtx = _mesa_create_context(&vis, NULL, &functions, (void *)c);
   if (!c->glCtx) {
      _mesa_free(c);
      return GL_FALSE;
   }

   /* Create module contexts */
   _swrast_CreateContext( ctx );
   _vbo_CreateContext( ctx );
   _tnl_CreateContext( ctx );
   _swsetup_CreateContext( ctx );
   _swsetup_Wakeup( ctx );


   /* use default TCL pipeline */
   {
      TNLcontext *tnl = TNL_CONTEXT(ctx);
      tnl->Driver.RunPipeline = _tnl_run_pipeline;
   }

   _mesa_enable_sw_extensions(ctx);

   return c->Base.Handle;
}