Exemplo n.º 1
0
/**
 * Destroy the per-context private information.
 * 
 * \internal
 * This function calls __DriverAPIRec::DestroyContext on \p contextPrivate, calls
 * drmDestroyContext(), and finally frees \p contextPrivate.
 */
static void
driDestroyContext(__DRIcontext *pcp)
{
    if (pcp) {
	(*pcp->driScreenPriv->DriverAPI.DestroyContext)(pcp);
	_mesa_free(pcp);
    }
}
void
_slang_delete_mempool(slang_mempool *pool)
{
   GLuint total = 0;
   while (pool) {
      slang_mempool *next = pool->Next;
      /*
      printf("DELETE MEMPOOL %u / %u  count=%u largest=%u\n",
             pool->Used, pool->Size, pool->Count, pool->Largest);
      */
      total += pool->Used;
      _mesa_free(pool->Data);
      _mesa_free(pool);
      pool = next;
   }
   /*printf("TOTAL ALLOCATED: %u\n", total);*/
}
Exemplo n.º 3
0
static void
driDeleteRenderbuffer(struct gl_renderbuffer *rb)
{
   /* don't free rb->Data  Chances are it's a memory mapped region for
    * the dri drivers.
    */
   _mesa_free(rb);
}
Exemplo n.º 4
0
static void
intel_delete_sync_object(GLcontext *ctx, struct gl_sync_object *s)
{
   struct intel_sync_object *sync = (struct intel_sync_object *)s;

   drm_intel_bo_unreference(sync->bo);
   _mesa_free(sync);
}
Exemplo n.º 5
0
/**
 * Destroy a GLcontext structure.
 *
 * \param ctx GL context.
 * 
 * Calls _mesa_free_context_data() and frees the GLcontext structure itself.
 */
void
_mesa_destroy_context( GLcontext *ctx )
{
   if (ctx) {
      _mesa_free_context_data(ctx);
      _mesa_free( (void *) ctx );
   }
}
Exemplo n.º 6
0
static void free_space(GLcontext *ctx)
{
   TNLcontext *tnl = TNL_CONTEXT(ctx);
   GLuint i;
   for (i = 0; i < tnl->nr_blocks; i++)
      _mesa_free(tnl->block[i]);
   tnl->nr_blocks = 0;
}
Exemplo n.º 7
0
/**
 * Delete an array object.
 * 
 * This function is intended to be called via
 * \c dd_function_table::DeleteArrayObject.
 */
void
_mesa_delete_array_object( GLcontext *ctx, struct gl_array_object *obj )
{
   (void) ctx;
   unbind_array_object_vbos(ctx, obj);
   _glthread_DESTROY_MUTEX(obj->Mutex);
   _mesa_free(obj);
}
Exemplo n.º 8
0
static void free_funcs( struct dynfn *l )
{
   struct dynfn *f, *tmp;
   foreach_s (f, tmp, l) {
      remove_from_list( f );
      _mesa_exec_free( f->code );
      _mesa_free( f );
   }
Exemplo n.º 9
0
/**
 * Deallocate buffer and everything attached to it.
 * Typically called via the gl_framebuffer->Delete() method.
 */
void
_mesa_destroy_framebuffer(struct gl_framebuffer *fb)
{
   if (fb) {
      _mesa_free_framebuffer_data(fb);
      _mesa_free(fb);
   }
}
Exemplo n.º 10
0
/**
 * Create a new intel_renderbuffer which corresponds to an on-screen window,
 * not a user-created renderbuffer.
 */
struct intel_renderbuffer *
intel_create_renderbuffer(gl_format format)
{
   GET_CURRENT_CONTEXT(ctx);

   struct intel_renderbuffer *irb;

   irb = CALLOC_STRUCT(intel_renderbuffer);
   if (!irb) {
      _mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer");
      return NULL;
   }

   _mesa_init_renderbuffer(&irb->Base, 0);
   irb->Base.ClassID = INTEL_RB_CLASS;

   switch (format) {
   case MESA_FORMAT_RGB565:
      irb->Base._BaseFormat = GL_RGB;
      irb->Base.DataType = GL_UNSIGNED_BYTE;
      break;
   case MESA_FORMAT_XRGB8888:
      irb->Base._BaseFormat = GL_RGB;
      irb->Base.DataType = GL_UNSIGNED_BYTE;
      break;
   case MESA_FORMAT_ARGB8888:
      irb->Base._BaseFormat = GL_RGBA;
      irb->Base.DataType = GL_UNSIGNED_BYTE;
      break;
   case MESA_FORMAT_Z16:
      irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
      irb->Base.DataType = GL_UNSIGNED_SHORT;
      break;
   case MESA_FORMAT_X8_Z24:
      irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
      irb->Base.DataType = GL_UNSIGNED_INT;
      break;
   case MESA_FORMAT_S8_Z24:
      irb->Base._BaseFormat = GL_DEPTH_STENCIL;
      irb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
      break;
   default:
      _mesa_problem(NULL,
                    "Unexpected intFormat in intel_create_renderbuffer");
      _mesa_free(irb);
      return NULL;
   }

   irb->Base.Format = format;
   irb->Base.InternalFormat = irb->Base._BaseFormat;

   /* intel-specific methods */
   irb->Base.Delete = intel_delete_renderbuffer;
   irb->Base.AllocStorage = intel_alloc_window_storage;
   irb->Base.GetPointer = intel_get_pointer;

   return irb;
}
Exemplo n.º 11
0
/**
 * Set the vertex/fragment program error state (position and error string).
 * This is generally called from within the parsers.
 */
void
_mesa_set_program_error(GLcontext *ctx, GLint pos, const char *string)
{
   ctx->Program.ErrorPos = pos;
   _mesa_free((void *) ctx->Program.ErrorString);
   if (!string)
      string = "";
   ctx->Program.ErrorString = _mesa_strdup(string);
}
Exemplo n.º 12
0
static void
xmesa_delete_renderbuffer(struct gl_renderbuffer *rb)
{
   /* XXX Note: the ximage or Pixmap attached to this renderbuffer
    * should probably get freed here, but that's currently done in
    * XMesaDestroyBuffer().
    */
   _mesa_free(rb);
}
Exemplo n.º 13
0
/** Called by gl_renderbuffer::Delete() */
static void
intel_delete_renderbuffer(struct gl_renderbuffer *rb)
{
   GET_CURRENT_CONTEXT(ctx);
   struct intel_context *intel = intel_context(ctx);
   struct intel_renderbuffer *irb = intel_renderbuffer(rb);

   ASSERT(irb);

   if (irb->span_cache != NULL)
      _mesa_free(irb->span_cache);

   if (intel && irb->region) {
      intel_region_release(&irb->region);
   }

   _mesa_free(irb);
}
Exemplo n.º 14
0
static GLvoid
pp_symbols_free (pp_symbols *self)
{
   GLuint i;

   for (i = 0; i < self->count; i++)
      pp_symbol_free (&self->symbols[i]);
   _mesa_free (self->symbols);
}
GLboolean radeonPairProgram(GLcontext *ctx, struct gl_program *program,
	const struct radeon_pair_handler* handler, void *userdata)
{
	struct pair_state s;

	_mesa_bzero(&s, sizeof(s));
	s.Ctx = ctx;
	s.Program = program;
	s.Handler = handler;
	s.UserData = userdata;
	s.Debug = (RADEON_DEBUG & DEBUG_PIXEL) ? GL_TRUE : GL_FALSE;
	s.Verbose = GL_FALSE && s.Debug;

	s.Instructions = (struct pair_state_instruction*)_mesa_calloc(
		sizeof(struct pair_state_instruction)*s.Program->NumInstructions);
	s.ValuePool = (struct reg_value*)_mesa_calloc(sizeof(struct reg_value)*s.Program->NumInstructions*4);
	s.ReaderPool = (struct reg_value_reader*)_mesa_calloc(
		sizeof(struct reg_value_reader)*s.Program->NumInstructions*12);

	if (s.Debug)
		_mesa_printf("Emit paired program\n");

	scan_instructions(&s);
	allocate_input_registers(&s);

	while(!s.Error &&
	      (s.ReadyTEX || s.ReadyRGB || s.ReadyAlpha || s.ReadyFullALU)) {
		if (s.ReadyTEX)
			emit_all_tex(&s);

		while(s.ReadyFullALU || s.ReadyRGB || s.ReadyAlpha)
			emit_alu(&s);
	}

	if (s.Debug)
		_mesa_printf(" END\n");

	_mesa_free(s.Instructions);
	_mesa_free(s.ValuePool);
	_mesa_free(s.ReaderPool);

	return !s.Error;
}
Exemplo n.º 16
0
/**
 * Free stage's private data.
 */
static void
free_normal_data(struct tnl_pipeline_stage *stage)
{
   struct normal_stage_data *store = NORMAL_STAGE_DATA(stage);
   if (store) {
      _mesa_vector4f_free( &store->normal );
      _mesa_free( store );
      stage->privatePtr = NULL;
   }
}
Exemplo n.º 17
0
/**
 * Deallocate/free a vertex/pixel buffer object.
 * Called via glDeleteBuffersARB().
 */
static void
st_bufferobj_free(GLcontext *ctx, struct gl_buffer_object *obj)
{
   struct st_buffer_object *st_obj = st_buffer_object(obj);

   if (st_obj->buffer) 
      pipe_buffer_reference(&st_obj->buffer, NULL);

   _mesa_free(st_obj);
}
Exemplo n.º 18
0
static void
driDestroyDrawable(__DRIdrawable *pdp)
{
    __DRIscreenPrivate *psp;

    if (pdp) {
	psp = pdp->driScreenPriv;
        (*psp->DriverAPI.DestroyBuffer)(pdp);
	if (pdp->pClipRects) {
	    _mesa_free(pdp->pClipRects);
	    pdp->pClipRects = NULL;
	}
	if (pdp->pBackClipRects) {
	    _mesa_free(pdp->pBackClipRects);
	    pdp->pBackClipRects = NULL;
	}
	_mesa_free(pdp);
    }
}
Exemplo n.º 19
0
void brw_destroy_state( struct brw_context *brw )
{
   if (brw->state.atoms) {
      _mesa_free(brw->state.atoms);
      brw->state.atoms = NULL;
   }

   brw_destroy_caches(brw);
   brw_destroy_batch_cache(brw);
   brw_destroy_pools(brw);   
}
Exemplo n.º 20
0
/* Create the device specific context.
 */
static GLboolean
fbCreateContext( const __GLcontextModes *glVisual,
		 __DRIcontextPrivate *driContextPriv,
		 void *sharedContextPrivate)
{
   fbContextPtr fbmesa;
   GLcontext *ctx, *shareCtx;
   struct dd_function_table functions;

   assert(glVisual);
   assert(driContextPriv);

   /* Allocate the Fb context */
   fbmesa = (fbContextPtr) _mesa_calloc( sizeof(*fbmesa) );
   if ( !fbmesa )
      return GL_FALSE;

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

   /* Allocate the Mesa context */
   if (sharedContextPrivate)
      shareCtx = ((fbContextPtr) sharedContextPrivate)->glCtx;
   else
      shareCtx = NULL;

   ctx = fbmesa->glCtx = _mesa_create_context(glVisual, shareCtx, 
					      &functions, (void *) fbmesa);
   if (!fbmesa->glCtx) {
      _mesa_free(fbmesa);
      return GL_FALSE;
   }
   driContextPriv->driverPrivate = fbmesa;

   /* 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 GL_TRUE;
}
Exemplo n.º 21
0
static void freeFragProgCache(GLcontext *ctx, struct r300_fragment_program_cont *cache)
{
    struct r300_fragment_program *tmp, *fp = cache->progs;

    while (fp) {
        tmp = fp->next;
        rc_constants_destroy(&fp->code.constants);
        _mesa_free(fp);
        fp = tmp;
    }
}
Exemplo n.º 22
0
GLboolean
MesaSoftwareRenderer::_BackRenderbufferStorage(GLcontext* ctx,
	struct gl_renderbuffer* render, GLenum internalFormat,
	GLuint width, GLuint height)
{
	struct msr_renderbuffer *mrb = msr_renderbuffer(render);
	_mesa_free(render->Data);
	_FrontRenderbufferStorage(ctx, render, internalFormat, width, height);
	render->Data = _mesa_malloc(mrb->Size);
	return GL_TRUE;
}
Exemplo n.º 23
0
static void radeonDeleteQuery(GLcontext *ctx, struct gl_query_object *q)
{
	struct radeon_query_object *query = (struct radeon_query_object *)q;

	radeon_print(RADEON_STATE, RADEON_NORMAL, "%s: query id %d\n", __FUNCTION__, q->Id);

	if (query->bo) {
		radeon_bo_unref(query->bo);
	}

	_mesa_free(query);
}
Exemplo n.º 24
0
void
st_free_translated_vertex_programs(struct st_context *st,
                                   struct translated_vertex_program *xvp)
{
   struct translated_vertex_program *next;

   while (xvp) {
      next = xvp->next;
      _mesa_free(xvp);
      xvp = next;
   }
}
Exemplo n.º 25
0
/**
 * This is called via __DRIscreenRec's createNewDrawable pointer.
 */
static __DRIdrawable *
driCreateNewDrawable(__DRIscreen *psp, const __DRIconfig *config,
		     drm_drawable_t hwDrawable, int renderType,
		     const int *attrs, void *data)
{
    __DRIdrawable *pdp;

    /* Since pbuffers are not yet supported, no drawable attributes are
     * supported either.
     */
    (void) attrs;

    pdp = _mesa_malloc(sizeof *pdp);
    if (!pdp) {
	return NULL;
    }

    pdp->loaderPrivate = data;
    pdp->hHWDrawable = hwDrawable;
    pdp->refcount = 0;
    pdp->pStamp = NULL;
    pdp->lastStamp = 0;
    pdp->index = 0;
    pdp->x = 0;
    pdp->y = 0;
    pdp->w = 0;
    pdp->h = 0;
    pdp->numClipRects = 0;
    pdp->numBackClipRects = 0;
    pdp->pClipRects = NULL;
    pdp->pBackClipRects = NULL;
    pdp->vblSeq = 0;
    pdp->vblFlags = 0;

    pdp->driScreenPriv = psp;
    pdp->driContextPriv = &psp->dummyContextPriv;

    if (!(*psp->DriverAPI.CreateBuffer)(psp, pdp, &config->modes,
					renderType == GLX_PIXMAP_BIT)) {
       _mesa_free(pdp);
       return NULL;
    }

    pdp->msc_base = 0;

    /* This special default value is replaced with the configured
     * default value when the drawable is first bound to a direct
     * rendering context. 
     */
    pdp->swap_interval = (unsigned)-1;

    return pdp;
}
Exemplo n.º 26
0
static void freeVertProgCache(GLcontext *ctx, struct r300_vertex_program_cont *cache)
{
    struct r300_vertex_program *tmp, *vp = cache->progs;

    while (vp) {
        tmp = vp->next;
        rc_constants_destroy(&vp->code.constants);
        _mesa_reference_vertprog(ctx, &vp->Base, NULL);
        _mesa_free(vp);
        vp = tmp;
    }
}
Exemplo n.º 27
0
static GLboolean
CreateContext(void)
{
   struct dd_function_table ddFuncs;
   GLvisual *vis;
   GLframebuffer *buf;
   GLcontext *ctx;
   CompilerContext *cc;

   vis = _mesa_create_visual(GL_TRUE, GL_FALSE, GL_FALSE, /* RGB */
                             8, 8, 8, 8,  /* color */
                             0, 0, 0,  /* z, stencil */
                             0, 0, 0, 0, 1);  /* accum */
   buf = _mesa_create_framebuffer(vis);

   cc = _mesa_calloc(sizeof(*cc));
   if (!vis || !buf || !cc) {
      if (vis)
         _mesa_destroy_visual(vis);
      if (buf)
         _mesa_destroy_framebuffer(buf);
      return GL_FALSE;
   }

   _mesa_init_driver_functions(&ddFuncs);
   ddFuncs.GetString = NULL;/*get_string;*/
   ddFuncs.UpdateState = UpdateState;
   ddFuncs.GetBufferSize = NULL;

   ctx = &cc->MesaContext;
   _mesa_initialize_context(ctx, vis, NULL, &ddFuncs, cc);
   _mesa_enable_sw_extensions(ctx);

   if (!_swrast_CreateContext( ctx ) ||
       !_vbo_CreateContext( ctx ) ||
       !_tnl_CreateContext( ctx ) ||
       !_swsetup_CreateContext( ctx )) {
      _mesa_destroy_visual(vis);
      _mesa_free_context_data(ctx);
      _mesa_free(cc);
      return GL_FALSE;
   }
   TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline;
   _swsetup_Wakeup( ctx );

   /* Override the context's default pragma settings */
   ctx->Shader.DefaultPragmas = Options.Pragmas;

   _mesa_make_current(ctx, buf, buf);

   return GL_TRUE;
}
Exemplo n.º 28
0
/**
 * Free a context's vertex/fragment program state
 */
void
_mesa_free_program_data(GLcontext *ctx)
{
#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
   _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, NULL);
   _mesa_delete_program_cache(ctx, ctx->VertexProgram.Cache);
#endif
#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program
   _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, NULL);
   _mesa_delete_program_cache(ctx, ctx->FragmentProgram.Cache);
#endif
   /* XXX probably move this stuff */
#if FEATURE_ATI_fragment_shader
   if (ctx->ATIFragmentShader.Current) {
      ctx->ATIFragmentShader.Current->RefCount--;
      if (ctx->ATIFragmentShader.Current->RefCount <= 0) {
         _mesa_free(ctx->ATIFragmentShader.Current);
      }
   }
#endif
   _mesa_free((void *) ctx->Program.ErrorString);
}
Exemplo n.º 29
0
/**
 * Deallocate/free a vertex/pixel buffer object.
 * Called via glDeleteBuffersARB().
 */
static void intel_bufferobj_free( GLcontext *ctx,
                                  struct gl_buffer_object *obj )
{
    struct intel_context *intel = intel_context(ctx);
    struct intel_buffer_object *intel_obj = intel_buffer_object(obj);

    assert(intel_obj);

    if (intel_obj->buffer)
        bmDeleteBuffers( intel->bm, 1, &intel_obj->buffer );

    _mesa_free(intel_obj);
}
Exemplo n.º 30
0
/**
 * Don't actually free memory, but mark it (for debugging).
 */
void
_slang_free(void *addr)
{
#if USE_MALLOC_FREE
   _mesa_free(addr);
#else
   if (addr) {
      GET_CURRENT_CONTEXT(ctx);
      slang_mempool *pool = (slang_mempool *) ctx->Shader.MemPool;
      ASSERT(is_valid_address(pool, addr));
   }
#endif
}