示例#1
0
static EGLBoolean
xlib_eglDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx)
{
   struct xlib_egl_context *context = lookup_context(ctx);
   if (context) {
      if (context->Base.IsBound) {
         context->Base.DeletePending = EGL_TRUE;
      }
      else {
         /* API-dependent clean-up */
         switch (context->Base.ClientAPI) {
         case EGL_OPENGL_ES_API:
            /* fall-through */
         case EGL_OPENGL_API:
            st_destroy_context(context->Context);
            break;
         default:
            assert(0);
         }
         free(context);
      }
      return EGL_TRUE;
   }
   else {
      _eglError(EGL_BAD_CONTEXT, "eglDestroyContext");
      return EGL_TRUE;
   }
}
示例#2
0
void
nouveau_context_destroy(__DRIcontextPrivate *driContextPriv)
{
	struct nouveau_context *nv = driContextPriv->driverPrivate;

	assert(nv);

	st_finish(nv->st);
	st_destroy_context(nv->st);

	FREE(nv);
}
示例#3
0
bool
hsp_delete_context(uint64 ctxId)
{
	TRACE("%s(ctxId: %d)\n", __FUNCTION__, ctxId);
	struct hsp_context *ctx = NULL;
	bool ret = false;

	if (!hsp_dev) {
		TRACE("%s> there's no hsp_dev so nothing to do\n",
			__FUNCTION__);
		return false;
	}

	pipe_mutex_lock(hsp_dev->mutex);

	ctx = hsp_lookup_context(ctxId);
	if (ctx) {
		TRACE("%s> found context: %p\n", __FUNCTION__, ctx);
		GLcontext *glctx = ctx->st->ctx;
		GET_CURRENT_CONTEXT(glcurctx);

		if (glcurctx == glctx)
			st_make_current(NULL, NULL, NULL);

		if (ctx->draw) {
			TRACE("%s> found context draw framebuffer, destroying: %p\n",
				__FUNCTION__, ctx->draw);
			framebuffer_destroy(ctx->draw);
		}
		if (ctx->read) {
			TRACE("%s> found context read framebuffer, destroying: %p\n",
				__FUNCTION__, ctx->read);
			framebuffer_destroy(ctx->read);
		}

		#warning TODO: destroy ctx->bitmap here ?
		
		st_destroy_context(ctx->st);

		FREE(ctx);

		hsp_dev->ctx_array[ctxId - 1].ctx = NULL;
		ret = true;
	}

	pipe_mutex_unlock(hsp_dev->mutex);
	return ret;
}
示例#4
0
static struct st_context_iface *
st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
                      const struct st_context_attribs *attribs,
                      enum st_context_error *error,
                      struct st_context_iface *shared_stctxi)
{
   struct st_context *shared_ctx = (struct st_context *) shared_stctxi;
   struct st_context *st;
   struct pipe_context *pipe;
   struct gl_config mode;
   gl_api api;

   if (!(stapi->profile_mask & (1 << attribs->profile)))
      return NULL;

   switch (attribs->profile) {
   case ST_PROFILE_DEFAULT:
      api = API_OPENGL;
      break;
   case ST_PROFILE_OPENGL_ES1:
      api = API_OPENGLES;
      break;
   case ST_PROFILE_OPENGL_ES2:
      api = API_OPENGLES2;
      break;
   case ST_PROFILE_OPENGL_CORE:
   default:
      *error = ST_CONTEXT_ERROR_BAD_API;
      return NULL;
      break;
   }

   pipe = smapi->screen->context_create(smapi->screen, NULL);
   if (!pipe) {
      *error = ST_CONTEXT_ERROR_NO_MEMORY;
      return NULL;
   }

   st_visual_to_context_mode(&attribs->visual, &mode);
   st = st_create_context(api, pipe, &mode, shared_ctx);
   if (!st) {
      *error = ST_CONTEXT_ERROR_NO_MEMORY;
      pipe->destroy(pipe);
      return NULL;
   }

   /* need to perform version check */
   if (attribs->major > 1 || attribs->minor > 0) {
      _mesa_compute_version(st->ctx);

      /* Is the actual version less than the requested version?  Mesa can't
       * yet enforce the added restrictions of a forward-looking context, so
       * fail that too.
       */
      if (st->ctx->VersionMajor * 10 + st->ctx->VersionMinor <
          attribs->major * 10 + attribs->minor
	  || (attribs->flags & ~ST_CONTEXT_FLAG_DEBUG) != 0) {
	 *error = ST_CONTEXT_ERROR_BAD_VERSION;
         st_destroy_context(st);
         return NULL;
      }
   }

   st->invalidate_on_gl_viewport =
      smapi->get_param(smapi, ST_MANAGER_BROKEN_INVALIDATE);

   st->iface.destroy = st_context_destroy;
   st->iface.flush = st_context_flush;
   st->iface.teximage = st_context_teximage;
   st->iface.copy = st_context_copy;
   st->iface.share = st_context_share;
   st->iface.st_context_private = (void *) smapi;

   *error = ST_CONTEXT_SUCCESS;
   return &st->iface;
}
示例#5
0
static void
st_context_destroy(struct st_context_iface *stctxi)
{
   struct st_context *st = (struct st_context *) stctxi;
   st_destroy_context(st);
}
示例#6
0
static struct st_context_iface *
st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
                      const struct st_context_attribs *attribs,
                      enum st_context_error *error,
                      struct st_context_iface *shared_stctxi)
{
   struct st_context *shared_ctx = (struct st_context *) shared_stctxi;
   struct st_context *st;
   struct pipe_context *pipe;
   struct gl_config mode;
   gl_api api;

   if (!(stapi->profile_mask & (1 << attribs->profile)))
      return NULL;

   switch (attribs->profile) {
   case ST_PROFILE_DEFAULT:
      api = API_OPENGL_COMPAT;
      break;
   case ST_PROFILE_OPENGL_ES1:
      api = API_OPENGLES;
      break;
   case ST_PROFILE_OPENGL_ES2:
      api = API_OPENGLES2;
      break;
   case ST_PROFILE_OPENGL_CORE:
      api = API_OPENGL_CORE;
      break;
   default:
      *error = ST_CONTEXT_ERROR_BAD_API;
      return NULL;
      break;
   }

   pipe = smapi->screen->context_create(smapi->screen, NULL);
   if (!pipe) {
      *error = ST_CONTEXT_ERROR_NO_MEMORY;
      return NULL;
   }

   st_visual_to_context_mode(&attribs->visual, &mode);
   st = st_create_context(api, pipe, &mode, shared_ctx, &attribs->options);
   if (!st) {
      *error = ST_CONTEXT_ERROR_NO_MEMORY;
      pipe->destroy(pipe);
      return NULL;
   }

   st->ctx->Debug.DebugOutput = GL_FALSE;
   if (attribs->flags & ST_CONTEXT_FLAG_DEBUG){
      st->ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_DEBUG_BIT;
      st->ctx->Debug.DebugOutput = GL_TRUE;
   }

   if (attribs->flags & ST_CONTEXT_FLAG_FORWARD_COMPATIBLE)
      st->ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;

   /* need to perform version check */
   if (attribs->major > 1 || attribs->minor > 0) {
      /* Is the actual version less than the requested version?
       */
      if (st->ctx->Version < attribs->major * 10 + attribs->minor) {
	 *error = ST_CONTEXT_ERROR_BAD_VERSION;
         st_destroy_context(st);
         return NULL;
      }
   }

   st->invalidate_on_gl_viewport =
      smapi->get_param(smapi, ST_MANAGER_BROKEN_INVALIDATE);

   st->iface.destroy = st_context_destroy;
   st->iface.flush = st_context_flush;
   st->iface.teximage = st_context_teximage;
   st->iface.copy = st_context_copy;
   st->iface.share = st_context_share;
   st->iface.st_context_private = (void *) smapi;
   st->iface.cso_context = st->cso_context;
   st->iface.pipe = st->pipe;

   *error = ST_CONTEXT_SUCCESS;
   return &st->iface;
}
示例#7
0
uint64
hsp_create_layer_context(Bitmap *bitmap, int layerPlane)
{
	TRACE("%s(bitmap: %p layerPlane: %d)\n", __FUNCTION__,
		bitmap, layerPlane);
	time_t total_beg, total_end;
	time_t beg, end;
	total_beg = time(NULL);
	struct hsp_context *ctx = NULL;
	struct pipe_screen *screen = NULL;
	GLvisual *visual = NULL;
	struct pipe_context *pipe = NULL;
	uint ctxId = 0;

	if (!hsp_dev) {
		TRACE("%s> there is no hsp_dev!\n", __FUNCTION__);
		return 0;
	}

	if (layerPlane != 0) {
		TRACE("%s> layerPlane != 0\n", __FUNCTION__);
		return 0;
	}

	ctx = CALLOC_STRUCT(hsp_context);
	if (!ctx) {
		TRACE("%s> can't alloc hsp_context!\n", __FUNCTION__);
		goto no_ctx;
	}

	ctx->bitmap = bitmap;
	ctx->colorSpace = get_bitmap_color_space(bitmap);
	ctx->draw = NULL;
	ctx->read = NULL;

	screen = hsp_dev->screen;

#ifdef DEBUG
    /* Unwrap screen */
    if (hsp_dev->trace_running)
        screen = trace_screen(screen)->screen;
#endif

	ulong options = hsp_dev->options;

	const GLboolean rgbFlag		= ((options & BGL_INDEX) == 0);
	const GLboolean alphaFlag	= ((options & BGL_ALPHA) == BGL_ALPHA);
	const GLboolean dblFlag		= ((options & BGL_DOUBLE) == BGL_DOUBLE);
	const GLboolean stereoFlag	= false;
	const GLint depth		= (options & BGL_DEPTH) ? 24 : 0;
	const GLint stencil		= (options & BGL_STENCIL) ? 8 : 0;
	const GLint accum		= 0;					// (options & BGL_ACCUM) ? 16 : 0;
	const GLint index		= 0;					// (options & BGL_INDEX) ? 32 : 0;
	const GLint red			= rgbFlag ? 8 : 0;
	const GLint green		= rgbFlag ? 8 : 0;
	const GLint blue		= rgbFlag ? 8 : 0;
	const GLint alpha		= alphaFlag ? 8 : 0;

	TRACE("rgb         :\t%d\n", (bool)rgbFlag);
	TRACE("alpha       :\t%d\n", (bool)alphaFlag);
	TRACE("dbl         :\t%d\n", (bool)dblFlag);
	TRACE("stereo      :\t%d\n", (bool)stereoFlag);
	TRACE("depth       :\t%d\n", depth);
	TRACE("stencil     :\t%d\n", stencil);
	TRACE("accum       :\t%d\n", accum);
	TRACE("index       :\t%d\n", index);
	TRACE("red         :\t%d\n", red);
	TRACE("green       :\t%d\n", green);
	TRACE("blue        :\t%d\n", blue);
	TRACE("alpha       :\t%d\n", alpha);

	visual = _mesa_create_visual(
		rgbFlag, dblFlag, stereoFlag, red, green, blue, alpha, index, depth,
		stencil, accum, accum, accum, alpha ? accum : 0, 1);

	TRACE("depthBits   :\t%d\n", visual->depthBits);
	TRACE("stencilBits :\t%d\n", visual->stencilBits);

	if (!visual) {
		TRACE("%s> can't create mesa visual!\n", __FUNCTION__);
		goto no_ctx_id;
	}

	pipe = hsp_dev->hsp_winsys->create_context(screen);

	if (!pipe) {
		TRACE("%s> can't create pipe!\n", __FUNCTION__);
		goto no_pipe;
	}

#ifdef DEBUG
    if (hsp_dev->trace_running)
        pipe = trace_context_create(hsp_dev->screen, pipe);
#endif

	assert(!pipe->priv);
	pipe->priv = bitmap;

	ctx->st = st_create_context(pipe, visual, NULL);
	if (!ctx->st) {
		TRACE("%s> can't create mesa statetracker context!\n",
			__FUNCTION__);
		goto no_st_ctx;
	}

	ctx->st->ctx->DriverCtx = ctx;

	pipe_mutex_lock(hsp_dev->mutex);
	uint64 i;
	for (i = 0; i < HSP_CONTEXT_MAX; i++) {
		if (hsp_dev->ctx_array[i].ctx == NULL) {
			hsp_dev->ctx_array[i].ctx = ctx;
			ctxId = i + 1;
			break;
		}
	}
	pipe_mutex_unlock(hsp_dev->mutex);

	if (ctxId != 0)
		return ctxId;

no_ctx_id:
	TRACE("%s> no_ctx_id!\n", __FUNCTION__);
    _mesa_destroy_visual(visual);
    st_destroy_context(ctx->st);
    goto no_pipe; /* st_context_destroy already destroy pipe */
no_st_ctx:
	TRACE("%s> no_st_ctx!\n", __FUNCTION__);
    pipe->destroy(pipe);
no_pipe:
	TRACE("%s> no_pipe!\n", __FUNCTION__);
    FREE(ctx);
no_ctx:
	TRACE("%s> no_ctx!\n", __FUNCTION__);
    return 0;
}
示例#8
0
文件: st_manager.c 项目: iquiw/xsrc
static struct st_context_iface *
st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
                      const struct st_context_attribs *attribs,
                      struct st_context_iface *shared_stctxi)
{
   struct st_context *shared_ctx = (struct st_context *) shared_stctxi;
   struct st_context *st;
   struct pipe_context *pipe;
   struct gl_config mode;
   gl_api api;

   if (!(stapi->profile_mask & (1 << attribs->profile)))
      return NULL;

   switch (attribs->profile) {
   case ST_PROFILE_DEFAULT:
      api = API_OPENGL;
      break;
   case ST_PROFILE_OPENGL_ES1:
      api = API_OPENGLES;
      break;
   case ST_PROFILE_OPENGL_ES2:
      api = API_OPENGLES2;
      break;
   case ST_PROFILE_OPENGL_CORE:
   default:
      return NULL;
      break;
   }

   pipe = smapi->screen->context_create(smapi->screen, NULL);
   if (!pipe)
      return NULL;

   st_visual_to_context_mode(&attribs->visual, &mode);
   st = st_create_context(api, pipe, &mode, shared_ctx);
   if (!st) {
      pipe->destroy(pipe);
      return NULL;
   }

   /* need to perform version check */
   if (attribs->major > 1 || attribs->minor > 0) {
      _mesa_compute_version(st->ctx);

      /* is the actual version less than the requested version? */
      if (st->ctx->VersionMajor * 10 + st->ctx->VersionMinor <
          attribs->major * 10 + attribs->minor) {
         st_destroy_context(st);
         return NULL;
      }
   }

   st->invalidate_on_gl_viewport =
      smapi->get_param(smapi, ST_MANAGER_BROKEN_INVALIDATE);

   st->iface.destroy = st_context_destroy;
   st->iface.notify_invalid_framebuffer =
      st_context_notify_invalid_framebuffer;
   st->iface.flush = st_context_flush;
   st->iface.teximage = st_context_teximage;
   st->iface.copy = st_context_copy;
   st->iface.share = st_context_share;
   st->iface.st_context_private = (void *) smapi;

   return &st->iface;
}