コード例 #1
0
ファイル: ggimesa.c プロジェクト: MttDs/new-rexeno-tindpe
int ggiMesaAttach(ggi_visual_t vis)
{
	int rc;

	GGIMESADPRINT_CORE("ggiMesaAttach() called\n");

	rc = ggiExtensionAttach(vis, _ggiMesaID);
	if (rc == 0)
	{
		int r, g, b, ci;
		GLboolean rgb, db;
		GLvisual *gl_visual;
		
		/* We are creating the primary instance */
		memset(LIBGGI_MESAEXT(vis), 0, sizeof(struct ggi_mesa_ext));
		LIBGGI_MESAEXT(vis)->update_state = (void *)_ggi_error;
		LIBGGI_MESAEXT(vis)->setup_driver = (void *)_ggi_error;

		/* Initialize default mesa visual */
		get_mode_info(vis, &r, &g, &b, &rgb, &db, &ci);
		gl_visual = &(LIBGGI_MESAEXT(vis)->mesa_visual.gl_visual);
		_mesa_initialize_visual(gl_visual,
					rgb, db, 0 /* No stereo */,
					r, g, b, 0 /* No alpha */, ci,
					0 /* No depth */, 0 /* No stencil */,
					0, 0, 0, 0 /* No accum */, 0);
		
		/* Now fake an "API change" so the right libs get loaded */
		changed(vis, GGI_CHG_APILIST);
	}
	
	return rc;
}
コード例 #2
0
ファイル: ggimesa.c プロジェクト: MttDs/new-rexeno-tindpe
static int changed(ggi_visual_t vis, int whatchanged)
{
	GLcontext *ctx;
	ctx = _mesa_get_current_context();

	GGIMESADPRINT_CORE("changed() called\n");
		
	switch (whatchanged) {
	case GGI_CHG_APILIST:
	{
		char api[GGI_MAX_APILEN];
		char args[GGI_MAX_APILEN];
		int i;
		const char *fname;
		ggi_dlhandle *lib;

		GLvisual *gl_vis = &(LIBGGI_MESAEXT(vis)->mesa_visual.gl_visual);
		GLframebuffer *gl_fb = &(LIBGGI_MESAEXT(vis)->mesa_buffer);
		
		/* Initialize the framebuffer to provide all necessary
		   buffers in software. The target libraries that are loaded
		   next are free to modify this according to their
		   capabilities. 
		 */
		 /* FIXME: if the target changes capabilities we'll leak 
		    swrast's memory !!! Need to deallocate first */
		_mesa_initialize_framebuffer(gl_fb, gl_vis,
					 gl_vis->depthBits > 0,
					 gl_vis->stencilBits > 0,
					 gl_vis->accumRedBits > 0,
					 gl_vis->alphaBits > 0);

		for (i = 0; ggiGetAPI(vis, i, api, args) == 0; i++) {
			strcat(api, "-mesa");
			GGIMESADPRINT_CORE("GGIMesa: looking for"
					"a sublib named %s\n", api);
			fname = ggMatchConfig(_ggimesaConfigHandle, api, NULL);
			if (fname == NULL) {
				/* No special implementation for this sublib */
				continue;
			}
			lib = ggiExtensionLoadDL(vis, fname, args, NULL,
						 SUBLIB_PREFIX);
		}

		/* The targets have cleared everything they can do from 
		   the framebuffer structure so we provide the rest in sw
		 */
		/*_swrast_alloc_buffers(gl_fb);*/
		
		break;
	} 
	}
	return 0;
}
コード例 #3
0
ファイル: ggimesa.c プロジェクト: MttDs/new-rexeno-tindpe
ggi_mesa_context_t ggiMesaCreateContext(ggi_visual_t vis)
{
	ggi_mesa_context_t ctx;
	int err;

	GGIMESADPRINT_CORE("ggiMesaCreateContext() called\n");
	
	ctx = (ggi_mesa_context_t)malloc(sizeof(struct ggi_mesa_context));
	if (!ctx) 
		return NULL;
	
	ctx->ggi_visual = vis;
	ctx->color = 0;

	ctx->gl_ctx =
	  _mesa_create_context(&(LIBGGI_MESAEXT(vis)->mesa_visual.gl_visual),
			       NULL, (void *) ctx, GL_FALSE);
	if (!ctx->gl_ctx)
		goto free_context;
	
        _mesa_enable_sw_extensions(ctx->gl_ctx);
	
	_swrast_CreateContext(ctx->gl_ctx);
	_vbo_CreateContext(ctx->gl_ctx);
	_tnl_CreateContext(ctx->gl_ctx);
	_swsetup_CreateContext(ctx->gl_ctx);
	
	gl_ggiSetupPointers(ctx->gl_ctx);

	/* Make sure that an appropriate sublib has been loaded */
	if (!LIBGGI_MESAEXT(ctx->ggi_visual)->setup_driver){
		GGIMESADPRINT_CORE("setup_driver==NULL!\n");
		GGIMESADPRINT_CORE("Please check your config files!\n");
		goto free_context;
	}

	/* Set up the sublib driver */
	err = LIBGGI_MESAEXT(ctx->ggi_visual)->setup_driver(ctx);
	if (err){
		GGIMESADPRINT_CORE("setup_driver failed (err = %d)", err);
		goto free_gl_context;
	}

	return ctx;
	
free_gl_context:
	_mesa_destroy_context(ctx->gl_ctx);
free_context:
	free(ctx);
	
	return NULL;
}
コード例 #4
0
ファイル: ggimesa.c プロジェクト: MttDs/new-rexeno-tindpe
int ggiMesaExtendVisual(ggi_visual_t vis, GLboolean alpha_flag,
			GLboolean stereo_flag, GLint depth_size,
			GLint stencil_size, GLint accum_red_size,
			GLint accum_green_size, GLint accum_blue_size,
			GLint accum_alpha_size, GLint num_samples)
{
        GLvisual *gl_vis = &(LIBGGI_MESAEXT(vis)->mesa_visual.gl_visual);
	int r, g, b, ci;
	GLboolean db, rgb;

	get_mode_info(vis, &r, &g, &b, &rgb, &db, &ci);
       
	/* Initialize the visual with the provided information */	
	_mesa_initialize_visual(gl_vis,
				rgb, db, stereo_flag,
				r, g, b, 0 /* FIXME */, ci,
				depth_size, stencil_size,
				accum_red_size, accum_green_size,
				accum_blue_size, accum_alpha_size, 0);

	/* Now fake an "API change" so the right libs get loaded. After all,
	   extending the visual by all these new buffers could be considered
	   a "mode change" which requires an "API change".
	 */
	changed(vis, GGI_CHG_APILIST);
	
	return 0;
}
コード例 #5
0
ファイル: ggimesa.c プロジェクト: MttDs/new-rexeno-tindpe
void ggiMesaMakeCurrent(ggi_mesa_context_t ctx, ggi_visual_t vis)
{
	GGIMESADPRINT_CORE("ggiMesaMakeCurrent(ctx = %p) called\n", ctx);

	/* FIXME: clean up where are ggi_vis */
	if (ctx->ggi_visual != vis) {
		GGIMESADPRINT_CORE("Cannot migrate GL contexts\n");
		return;
	}
	
	_mesa_make_current(ctx->gl_ctx, &LIBGGI_MESAEXT(vis)->mesa_buffer);
}
コード例 #6
0
ファイル: ggimesa.c プロジェクト: MttDs/new-rexeno-tindpe
static void gl_ggiUpdateState(GLcontext *ctx, GLuint new_state)
{
	ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
	
	GGIMESADPRINT_CORE("gl_ggiUpdateState() called\n");
		
	/* Propogate statechange information to swrast and swrast_setup
	 * modules.  The GGI driver has no internal GL-dependent state.
	 */
	_swrast_InvalidateState(ctx, new_state);
	_swsetup_InvalidateState(ctx, new_state);
	_tnl_InvalidateState(ctx, new_state);
	
	/* XXX: Better use an assertion that bails out here on failure */
	if (!LIBGGI_MESAEXT(ggi_ctx->ggi_visual)->update_state) {
		GGIMESADPRINT_CORE("update_state == NULL!\n");
		GGIMESADPRINT_CORE("Please check your config files!\n");
		ggiPanic("");
	}

	LIBGGI_MESAEXT(ggi_ctx->ggi_visual)->update_state(ggi_ctx);
}
コード例 #7
0
static int GGIdlinit(ggi_visual *vis, struct ggi_dlhandle *dlh,
			const char *args, void *argptr, uint32 *dlret)
{
	struct genkgi_priv_mesa *priv;
	char libname[256], libargs[256];
	int id, err;
	struct stat junk;
	ggifunc_getapi *oldgetapi;

	GGIMESADPRINT_CORE("display-fbdev-kgicon-mesa: GGIdlinit start\n");
	
	GENKGI_PRIV_MESA(vis) = priv = malloc(sizeof(struct genkgi_priv_mesa));
	if (priv == NULL) 
	{
		fprintf(stderr, "Failed to allocate genkgi private data\n");
		return GGI_DL_ERROR;
	}
	
	priv->oldpriv = GENKGI_PRIV(vis);
#if 0
	err = ggLoadConfig(conffile, &_configHandle);
	if (err != GGI_OK)
	{
		gl_ggiPrint("display-fbdev-kgicon-mesa: Couldn't open %s\n", conffile);
		return err;
	}

	/* Hack city here.  We need to probe the KGI driver properly for
	 * suggest-strings to discover the acceleration type(s).
	 */
	priv->have_accel = 0;

	if (stat("/proc/gfx0", &junk) == 0)
	{
		sprintf(priv->accel, "%s%s", accel_prefix, "d3dim");
		priv->have_accel = 1;
		GGIMESADPRINT_CORE("display-fbdev-kgicon-mesa: Using accel: \"%s\"\n", priv->accel);
	}

	/* Mode management */
	vis->opdisplay->getapi = GGIMesa_genkgi_getapi;	
	ggiIndicateChange(vis, GGI_CHG_APILIST);
	
	/* Give the accel sublibs a chance to set up a driver */
	if (priv->have_accel == 1)
	{
		oldgetapi = vis->opdisplay->getapi;
		vis->opdisplay->getapi = GGIMesa_genkgi_getapi;
		changed(vis, GGI_CHG_APILIST);
		/* If the accel sublibs didn't produce, back up
		 * and keep looking */
		if ((LIBGGI_MESAEXT(vis)->update_state == NULL) ||
		    (LIBGGI_MESAEXT(vis)->setup_driver == NULL))
		  vis->opdisplay->getapi = oldgetapi;
	}
	
	LIBGGI_MESAEXT(vis)->update_state = genkgi_update_state;
	LIBGGI_MESAEXT(vis)->setup_driver = genkgi_setup_driver;
#endif	
	GGIMESADPRINT_CORE("display-fbdev-kgicon-mesa: GGIdlinit finished\n");

	*dlret = GGI_DL_OPDRAW;
	return 0;
}