• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ MALLOC_STRUCT函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中MALLOC_STRUCT函数的典型用法代码示例。如果您正苦于以下问题:C++ MALLOC_STRUCT函数的具体用法?C++ MALLOC_STRUCT怎么用?C++ MALLOC_STRUCT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MALLOC_STRUCT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: _mesa_PushClientAttrib

void
_mesa_PushClientAttrib(GLbitfield mask)
{
   struct gl_attrib_node *newnode;
   struct gl_attrib_node *head;

   GET_CURRENT_CONTEXT(ctx);
   ASSERT_OUTSIDE_BEGIN_END(ctx);

   if (ctx->ClientAttribStackDepth >= MAX_CLIENT_ATTRIB_STACK_DEPTH) {
      _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushClientAttrib" );
      return;
   }

   /* Build linked list of attribute nodes which save all attribute */
   /* groups specified by the mask. */
   head = NULL;

   if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
      struct gl_pixelstore_attrib *attr;
      /* packing attribs */
      attr = MALLOC_STRUCT( gl_pixelstore_attrib );
      MEMCPY( attr, &ctx->Pack, sizeof(struct gl_pixelstore_attrib) );
      newnode = new_attrib_node( GL_CLIENT_PACK_BIT );
      newnode->data = attr;
      newnode->next = head;
      head = newnode;
      /* unpacking attribs */
      attr = MALLOC_STRUCT( gl_pixelstore_attrib );
      MEMCPY( attr, &ctx->Unpack, sizeof(struct gl_pixelstore_attrib) );
      newnode = new_attrib_node( GL_CLIENT_UNPACK_BIT );
      newnode->data = attr;
      newnode->next = head;
      head = newnode;
   }
   if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
      struct gl_array_attrib *attr;
      attr = MALLOC_STRUCT( gl_array_attrib );
      MEMCPY( attr, &ctx->Array, sizeof(struct gl_array_attrib) );
      newnode = new_attrib_node( GL_CLIENT_VERTEX_ARRAY_BIT );
      newnode->data = attr;
      newnode->next = head;
      head = newnode;
   }

   ctx->ClientAttribStack[ctx->ClientAttribStackDepth] = head;
   ctx->ClientAttribStackDepth++;
}
开发者ID:DavidGriffith,项目名称:finx,代码行数:48,代码来源:attrib.c


示例2: MALLOC_STRUCT

struct dynfn *tnl_makeX86Attr4ubv( TNLcontext *tnl, int key )
{
   struct dynfn *dfn = MALLOC_STRUCT( dynfn );
   insert_at_head( &tnl->dfn_cache.Color4ubv, dfn );
   dfn->key = key;

   if (TNL_DEBUG & DEBUG_CODEGEN)
      _mesa_debug(NULL,  "%s 0x%08x\n", __FUNCTION__, key );

   if (key & TNL_CP_VC_FRMT_PKCOLOR) {
      static  char temp[] = {
	 0x8b, 0x44, 0x24, 0x04,        /*  mov    0x4(%esp,1),%eax */
	 0xba, 0x78, 0x56, 0x34, 0x12,  /*  mov    $DEST,%edx */
	 0x8b, 0x00,                	/*  mov    (%eax),%eax */
	 0x89, 0x02,               	/*  mov    %eax,(%edx) */
	 0xc3,                     	/*  ret     */
      };

      dfn->code = ALIGN_MALLOC( sizeof(temp), 16 );
      memcpy (dfn->code, temp, sizeof(temp));
      FIXUP(dfn->code, 5, 0x12345678, (int)tnl->ubytecolorptr); 
      return dfn;
   } 
   else {
      static  char temp[] = {
	 0x53,					/* push   %ebx */
	 0xba, 0x00, 0x00, 0x00, 0x00,       	/* mov    $0x0,%edx */
	 0x31, 0xc0,                    	/* xor    %eax,%eax */
	 0x31, 0xc9,                    	/* xor    %ecx,%ecx */
	 0x8b, 0x5c, 0x24, 0x08,		/* mov	  0x8(%esp,1), %ebx */
	 0x8b, 0x1b,				/* mov    (%ebx), %ebx */
	 0x88, 0xd8,				/* mov    %bl, %al */
	 0x88, 0xf9, 	         		/* mov    %bh, %cl */
	 0x8b, 0x04, 0x82,              	/* mov    (%edx,%eax,4),%eax */
	 0x8b, 0x0c, 0x8a,              	/* mov    (%edx,%ecx,4),%ecx */
	 0xa3, 0xaf, 0xbe, 0xad, 0xde,       	/* mov    %eax,0xdeadbeaf */
	 0x89, 0x0d, 0xaf, 0xbe, 0xad, 0xde,   	/* mov    %ecx,0xdeadbeaf */
	 0x31, 0xc0,                    	/* xor    %eax,%eax */
	 0x31, 0xc9,                    	/* xor    %ecx,%ecx */
	 0xc1, 0xeb, 0x10,			/* shr    $0x10, %ebx */
	 0x88, 0xd8,				/* mov    %bl, %al */
	 0x88, 0xf9, 	         		/* mov    %bh, %cl */
	 0x8b, 0x04, 0x82,               	/* mov    (%edx,%eax,4),%eax */
	 0x8b, 0x0c, 0x8a,               	/* mov    (%edx,%ecx,4),%ecx */
	 0xa3, 0xaf, 0xbe, 0xad, 0xde,       	/* mov    %eax,0xdeadbeaf */
	 0x89, 0x0d, 0xaf, 0xbe, 0xad, 0xde,   	/* mov    %ecx,0xdeadbeaf */
	 0x5b,                      		/* pop    %ebx */
	 0xc3,                          	/* ret     */
      };

      dfn->code = ALIGN_MALLOC( sizeof(temp), 16 );
      memcpy (dfn->code, temp, sizeof(temp));
      FIXUP(dfn->code, 2, 0x00000000, (int)_mesa_ubyte_to_float_color_tab); 
      FIXUP(dfn->code, 27, 0xdeadbeaf, (int)tnl->floatcolorptr); 
      FIXUP(dfn->code, 33, 0xdeadbeaf, (int)tnl->floatcolorptr+4); 
      FIXUP(dfn->code, 55, 0xdeadbeaf, (int)tnl->floatcolorptr+8); 
      FIXUP(dfn->code, 61, 0xdeadbeaf, (int)tnl->floatcolorptr+12); 
      return dfn;
   }
}
开发者ID:aosm,项目名称:X11,代码行数:60,代码来源:t_vtx_x86.c


示例3: movq

static struct dynfn *makeSSENormal3fv( GLcontext *ctx, const int *key )
{
   /* Requires P4 (sse2?)
    */
   static unsigned char temp[] = {
      0x8b, 0x44, 0x24, 0x04,          	/*  mov    0x4(%esp,1),%eax */
      0xba, 0x78, 0x56, 0x34, 0x12,   	/*  mov    $0x12345678,%edx */
      0xf3, 0x0f, 0x7e, 0x00,          	/*  movq   (%eax),%xmm0 */
      0x66, 0x0f, 0x6e, 0x48, 0x08,    	/*  movd   0x8(%eax),%xmm1 */
      0x66, 0x0f, 0xd6, 0x42, 0x0c,    	/*  movq   %xmm0,0xc(%edx) */
      0x66, 0x0f, 0x7e, 0x4a, 0x14,    	/*  movd   %xmm1,0x14(%edx) */
      0xc3,                   	        /*  ret     */
   };


   struct dynfn *dfn = MALLOC_STRUCT( dynfn );
   r200ContextPtr rmesa = R200_CONTEXT(ctx);
   insert_at_head( &rmesa->vb.dfn_cache.Normal3fv, dfn );
   dfn->key[0] = key[0];
   dfn->key[1] = key[1];

   dfn->code = ALIGN_MALLOC( sizeof(temp), 16 );
   memcpy (dfn->code, temp, sizeof(temp));
   FIXUP(dfn->code, 5, 0x0, (int)vb.normalptr); 
   return dfn;
}
开发者ID:dikerex,项目名称:theqvd,代码行数:26,代码来源:r200_vtxfmt_sse.c


示例4: sp_alloc_tile

static struct softpipe_cached_tile *
sp_alloc_tile(struct softpipe_tile_cache *tc)
{
    struct softpipe_cached_tile * tile = MALLOC_STRUCT(softpipe_cached_tile);
    if (!tile)
    {
        /* in this case, steal an existing tile */
        if (!tc->tile)
        {
            unsigned pos;
            for (pos = 0; pos < NUM_ENTRIES; ++pos) {
                if (!tc->entries[pos])
                    continue;

                sp_flush_tile(tc, pos);
                tc->tile = tc->entries[pos];
                tc->entries[pos] = NULL;
                break;
            }

            /* this should never happen */
            if (!tc->tile)
                abort();
        }

        tile = tc->tile;
        tc->tile = NULL;

        tc->last_tile_addr.bits.invalid = 1;
    }
    return tile;
}
开发者ID:mlankhorst,项目名称:Mesa-3D,代码行数:32,代码来源:sp_tile_cache.c


示例5: nvc0_so_target_create

static struct pipe_stream_output_target *
nvc0_so_target_create(struct pipe_context *pipe,
                      struct pipe_resource *res,
                      unsigned offset, unsigned size)
{
   struct nvc0_so_target *targ = MALLOC_STRUCT(nvc0_so_target);
   if (!targ)
      return NULL;

   targ->pq = pipe->create_query(pipe, NVC0_QUERY_TFB_BUFFER_OFFSET);
   if (!targ->pq) {
      FREE(targ);
      return NULL;
   }
   targ->clean = TRUE;

   targ->pipe.buffer_size = size;
   targ->pipe.buffer_offset = offset;
   targ->pipe.context = pipe;
   targ->pipe.buffer = NULL;
   pipe_resource_reference(&targ->pipe.buffer, res);
   pipe_reference_init(&targ->pipe.reference, 1);

   return &targ->pipe;
}
开发者ID:Forzaferrarileo,项目名称:mesa,代码行数:25,代码来源:nvc0_state.c


示例6: _mesa_new_query_object

/**
 * Allocate a new query object.  This is a fallback routine called via
 * ctx->Driver.NewQueryObject().
 * \param ctx - rendering context
 * \param id - the new object's ID
 * \return pointer to new query_object object or NULL if out of memory.
 */
struct gl_query_object *
_mesa_new_query_object(struct gl_context *ctx, GLuint id)
{
   struct gl_query_object *q = MALLOC_STRUCT(gl_query_object);
   (void) ctx;
   if (q) {
      q->Id = id;
      q->Result = 0;
      q->Active = GL_FALSE;

      /* This is to satisfy the language of the specification: "In the initial
       * state of a query object, the result is available" (OpenGL 3.1 §
       * 2.13).
       */
      q->Ready = GL_TRUE;

      /* OpenGL 3.1 § 2.13 says about GenQueries, "These names are marked as
       * used, but no object is associated with them until the first time they
       * are used by BeginQuery." Since our implementation actually does
       * allocate an object at this point, use a flag to indicate that this
       * object has not yet been bound so should not be considered a query.
       */
      q->EverBound = GL_FALSE;
   }
   return q;
}
开发者ID:sheldonrobinson,项目名称:VcXsrv,代码行数:33,代码来源:queryobj.c


示例7: nvc0_so_target_create

static struct pipe_stream_output_target *
nvc0_so_target_create(struct pipe_context *pipe,
                      struct pipe_resource *res,
                      unsigned offset, unsigned size)
{
   struct nv04_resource *buf = (struct nv04_resource *)res;
   struct nvc0_so_target *targ = MALLOC_STRUCT(nvc0_so_target);
   if (!targ)
      return NULL;

   targ->pq = pipe->create_query(pipe, NVC0_HW_QUERY_TFB_BUFFER_OFFSET, 0);
   if (!targ->pq) {
      FREE(targ);
      return NULL;
   }
   targ->clean = true;

   targ->pipe.buffer_size = size;
   targ->pipe.buffer_offset = offset;
   targ->pipe.context = pipe;
   targ->pipe.buffer = NULL;
   pipe_resource_reference(&targ->pipe.buffer, res);
   pipe_reference_init(&targ->pipe.reference, 1);

   assert(buf->base.target == PIPE_BUFFER);
   util_range_add(&buf->valid_buffer_range, offset, offset + size);

   return &targ->pipe;
}
开发者ID:Unr34ler,项目名称:mesa,代码行数:29,代码来源:nvc0_state.c


示例8: _mesa_HashInsert

/**
 * Insert into the hash table.  If an entry with this key already exists
 * we'll replace the existing entry.
 * \param table - the hash table
 * \param key - the key (not zero)
 * \param data - pointer to user data
 */
void _mesa_HashInsert(struct _mesa_HashTable *table, GLuint key, void *data)
{
   /* search for existing entry with this key */
   GLuint pos;
   struct HashEntry *entry;

   assert(table);
   assert(key);

   _glthread_LOCK_MUTEX(table->Mutex);

   if (key > table->MaxKey)
      table->MaxKey = key;

   pos = key & (TABLE_SIZE-1);
   entry = table->Table[pos];
   while (entry) {
      if (entry->Key == key) {
         /* replace entry's data */
	 entry->Data = data;
         _glthread_UNLOCK_MUTEX(table->Mutex);
	 return;
      }
      entry = entry->Next;
   }

   /* alloc and insert new table entry */
   entry = MALLOC_STRUCT(HashEntry);
   entry->Key = key;
   entry->Data = data;
   entry->Next = table->Table[pos];
   table->Table[pos] = entry;

   _glthread_UNLOCK_MUTEX(table->Mutex);
}
开发者ID:aosm,项目名称:X11,代码行数:42,代码来源:hash.c


示例9: MALLOC_STRUCT

struct dynfn *radeon_makeX86Color4ubv( GLcontext *ctx, int key )
{
   struct dynfn *dfn = MALLOC_STRUCT( dynfn );
   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);


   if (RADEON_DEBUG & DEBUG_CODEGEN)
      fprintf(stderr, "%s 0x%08x\n", __FUNCTION__, key );

   if (key & RADEON_CP_VC_FRMT_PKCOLOR) {
      DFN ( _x86_Color4ubv_ub, rmesa->vb.dfn_cache.Color4ubv);
      FIXUP(dfn->code, 5, 0x12345678, (int)rmesa->vb.colorptr); 
      return dfn;
   } 
   else {

      DFN ( _x86_Color4ubv_4f, rmesa->vb.dfn_cache.Color4ubv);
      FIXUP(dfn->code, 2, 0x00000000, (int)_mesa_ubyte_to_float_color_tab); 
      FIXUP(dfn->code, 27, 0xdeadbeaf, (int)rmesa->vb.floatcolorptr); 
      FIXUP(dfn->code, 33, 0xdeadbeaf, (int)rmesa->vb.floatcolorptr+4); 
      FIXUP(dfn->code, 55, 0xdeadbeaf, (int)rmesa->vb.floatcolorptr+8); 
      FIXUP(dfn->code, 61, 0xdeadbeaf, (int)rmesa->vb.floatcolorptr+12); 
      return dfn;
   }
}
开发者ID:aosm,项目名称:X11,代码行数:25,代码来源:radeon_vtxfmt_x86.c


示例10: nv50_so_target_create

static struct pipe_stream_output_target *
nv50_so_target_create(struct pipe_context *pipe,
                      struct pipe_resource *res,
                      unsigned offset, unsigned size)
{
   struct nv04_resource *buf = (struct nv04_resource *)res;
   struct nv50_so_target *targ = MALLOC_STRUCT(nv50_so_target);
   if (!targ)
      return NULL;

   if (nouveau_context(pipe)->screen->class_3d >= NVA0_3D_CLASS) {
      targ->pq = pipe->create_query(pipe,
                                    NVA0_QUERY_STREAM_OUTPUT_BUFFER_OFFSET, 0);
      if (!targ->pq) {
         FREE(targ);
         return NULL;
      }
   } else {
      targ->pq = NULL;
   }
   targ->clean = TRUE;

   targ->pipe.buffer_size = size;
   targ->pipe.buffer_offset = offset;
   targ->pipe.context = pipe;
   targ->pipe.buffer = NULL;
   pipe_resource_reference(&targ->pipe.buffer, res);
   pipe_reference_init(&targ->pipe.reference, 1);

   assert(buf->base.target == PIPE_BUFFER);
   util_range_add(&buf->valid_buffer_range, offset, offset + size);

   return &targ->pipe;
}
开发者ID:threader,项目名称:mesa-10.6.3-ppc-r300-debian,代码行数:34,代码来源:nv50_state.c


示例11: MALLOC_STRUCT

struct dynfn *r200_makeX86Color4ubv( GLcontext *ctx, const int *key )
{
   struct dynfn *dfn = MALLOC_STRUCT( dynfn );
   r200ContextPtr rmesa = R200_CONTEXT(ctx);


   if (R200_DEBUG & DEBUG_CODEGEN)
      fprintf(stderr, "%s 0x%08x\n", __FUNCTION__, key[0] );

   if (VTX_COLOR(key[0],0) == R200_VTX_PK_RGBA) {
      DFN ( _x86_Color4ubv_ub, rmesa->vb.dfn_cache.Color4ubv);
      FIXUP(dfn->code, 5, 0x12345678, (int)vb.colorptr); 
      return dfn;
   } 
   else {

      DFN ( _x86_Color4ubv_4f, rmesa->vb.dfn_cache.Color4ubv);
      FIXUP(dfn->code, 2, 0x00000000, (int)_mesa_ubyte_to_float_color_tab); 
      FIXUP(dfn->code, 27, 0xdeadbeaf, (int)vb.floatcolorptr); 
      FIXUP(dfn->code, 33, 0xdeadbeaf, (int)vb.floatcolorptr+4); 
      FIXUP(dfn->code, 55, 0xdeadbeaf, (int)vb.floatcolorptr+8); 
      FIXUP(dfn->code, 61, 0xdeadbeaf, (int)vb.floatcolorptr+12); 
      return dfn;
   }
}
开发者ID:dikerex,项目名称:theqvd,代码行数:25,代码来源:r200_vtxfmt_x86.c


示例12: R200_CONTEXT

struct dynfn *r200_makeX86Vertex3fv( GLcontext *ctx, const int *key )
{
   r200ContextPtr rmesa = R200_CONTEXT(ctx);
   struct dynfn *dfn = MALLOC_STRUCT( dynfn );

   if (R200_DEBUG & DEBUG_CODEGEN)
      fprintf(stderr, "%s 0x%08x 0x%08x %d\n", __FUNCTION__, 
	      key[0], key[1], vb.vertex_size );

   switch (vb.vertex_size) {
   case 6: {

      DFN ( _x86_Vertex3fv_6, rmesa->vb.dfn_cache.Vertex3fv );
      FIXUP(dfn->code, 1, 0x00000000, (int)&vb.dmaptr);
      FIXUP(dfn->code, 27, 0x0000001c, (int)&vb.vertex[3]);
      FIXUP(dfn->code, 33, 0x00000020, (int)&vb.vertex[4]);
      FIXUP(dfn->code, 45, 0x00000024, (int)&vb.vertex[5]);
      FIXUP(dfn->code, 56, 0x00000000, (int)&vb.dmaptr);
      FIXUP(dfn->code, 61, 0x00000004, (int)&vb.counter);
      FIXUP(dfn->code, 67, 0x00000004, (int)&vb.counter);
      FIXUP(dfn->code, 76, 0x00000008, (int)&vb.notify);
      break;
   }
   

   case 8: {

      DFN ( _x86_Vertex3fv_8, rmesa->vb.dfn_cache.Vertex3fv );
      FIXUP(dfn->code, 1, 0x00000000, (int)&vb.dmaptr);
      FIXUP(dfn->code, 27, 0x0000001c, (int)&vb.vertex[3]);
      FIXUP(dfn->code, 33, 0x00000020, (int)&vb.vertex[4]);
      FIXUP(dfn->code, 45, 0x0000001c, (int)&vb.vertex[5]);
      FIXUP(dfn->code, 51, 0x00000020, (int)&vb.vertex[6]);
      FIXUP(dfn->code, 63, 0x00000024, (int)&vb.vertex[7]);
      FIXUP(dfn->code, 74, 0x00000000, (int)&vb.dmaptr);
      FIXUP(dfn->code, 79, 0x00000004, (int)&vb.counter);
      FIXUP(dfn->code, 85, 0x00000004, (int)&vb.counter);
      FIXUP(dfn->code, 94, 0x00000008, (int)&vb.notify);
      break;
   }
   


   default: {

      DFN ( _x86_Vertex3fv, rmesa->vb.dfn_cache.Vertex3fv );
      FIXUP(dfn->code, 8, 0x01010101, (int)&vb.dmaptr);
      FIXUP(dfn->code, 32, 0x00000006, vb.vertex_size-3);
      FIXUP(dfn->code, 37, 0x00000058, (int)&vb.vertex[3]);
      FIXUP(dfn->code, 45, 0x01010101, (int)&vb.dmaptr);
      FIXUP(dfn->code, 50, 0x02020202, (int)&vb.counter);
      FIXUP(dfn->code, 58, 0x02020202, (int)&vb.counter);
      FIXUP(dfn->code, 67, 0x0, (int)&vb.notify);
   break;
   }
   }

   return dfn;
}
开发者ID:dikerex,项目名称:theqvd,代码行数:59,代码来源:r200_vtxfmt_x86.c


示例13: MALLOC_STRUCT

static struct tnl_primitive_store *alloc_prim_store( GLcontext *ctx )
{
   struct tnl_primitive_store *store = MALLOC_STRUCT(tnl_primitive_store);
   (void) ctx;
   store->used = 0;
   store->refcount = 1;
   return store;
}
开发者ID:BackupTheBerlios,项目名称:dri-ex-svn,代码行数:8,代码来源:t_save_api.c


示例14: lll_get_symbol

struct lll_object *
lll_get_symbol(const char *symbol_string) {
    if (!lll_correct_symbol_string_p(symbol_string)) {
        lll_error(2, symbol_string, __FILE__, __LINE__);
        return NULL;
    }

    char *lowercase_version = lll_to_lowercase(symbol_string);

    if (strcmp(lowercase_version, "nil") == 0) {
        free(lowercase_version);
        return NULL;
    }

    struct lll_symbol_entry *entry = &hash_table[hash_func(lowercase_version)];

    while (true) {
        /* haven't binded symbols. */
        if (entry == NULL) {
            entry = MALLOC_STRUCT(lll_symbol_entry);
            entry->string = lowercase_version;

            struct lll_object *obj = lll_csymbol(entry->string);
            //obj->d.symbol->pair->d.obj = lll_cons(LLL_UNDEFINED(), NULL);

            entry->symbol = obj;
            entry->another_entry = NULL;

            return entry->symbol;
        }

        if (entry->string == NULL) {
            entry->string = lowercase_version;
            entry->symbol = lll_csymbol(entry->string);
            entry->symbol->d.symbol->pair->d.obj = lll_cons(LLL_UNDEFINED(), NULL);

            return entry->symbol;
        }

        if (strcmp(entry->string, lowercase_version) == 0) {
            /* So we have one copy in hash_table. Free second. */
            free(lowercase_version);

            /* string not binded yet */
            if (entry->symbol == NULL) {
                entry->symbol = lll_csymbol(entry->string);
                entry->symbol->d.symbol->pair->d.obj = lll_cons(LLL_UNDEFINED(), NULL);

                return entry->symbol;
            }
            /* string binded */
            else {
                return entry->symbol;
            }
        }
        entry = entry->another_entry;
    }
}
开发者ID:vladimir-vg,项目名称:lll,代码行数:58,代码来源:lll_symtable.c


示例15: new_attrib_node

/*
 * Allocate a new attribute state node.  These nodes have a
 * "kind" value and a pointer to a struct of state data.
 */
static struct gl_attrib_node *
new_attrib_node( GLbitfield kind )
{
   struct gl_attrib_node *an = MALLOC_STRUCT(gl_attrib_node);
   if (an) {
      an->kind = kind;
   }
   return an;
}
开发者ID:DavidGriffith,项目名称:finx,代码行数:13,代码来源:attrib.c


示例16: _mesa_new_sync_object

static struct gl_sync_object *
_mesa_new_sync_object(GLcontext *ctx, GLenum type)
{
   struct gl_sync_object *s = MALLOC_STRUCT(gl_sync_object);
   (void) ctx;
   (void) type;

   return s;
}
开发者ID:CPFDSoftware-Tony,项目名称:gmv,代码行数:9,代码来源:syncobj.c


示例17: _mesa_new_texture_object

/**
 * Allocate and initialize a new texture object.  But don't put it into the
 * texture object hash table.
 *
 * Called via ctx->Driver.NewTextureObject, unless overridden by a device
 * driver.
 * 
 * \param shared the shared GL state structure to contain the texture object
 * \param name integer name for the texture object
 * \param target either GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D,
 * GL_TEXTURE_CUBE_MAP_ARB or GL_TEXTURE_RECTANGLE_NV.  zero is ok for the sake
 * of GenTextures()
 *
 * \return pointer to new texture object.
 */
struct gl_texture_object *
_mesa_new_texture_object( struct gl_context *ctx, GLuint name, GLenum target )
{
   struct gl_texture_object *obj;
   (void) ctx;
   obj = MALLOC_STRUCT(gl_texture_object);
   _mesa_initialize_texture_object(obj, name, target);
   return obj;
}
开发者ID:jay8muel,项目名称:Renderfusion,代码行数:24,代码来源:texobj.c


示例18: translate_cache_create

struct translate_cache * translate_cache_create( void )
{
   struct translate_cache *cache = MALLOC_STRUCT(translate_cache);
   if (cache == NULL) {
      return NULL;
   }

   cache->hash = cso_hash_create();
   return cache;
}
开发者ID:Bluerise,项目名称:bitrig-xenocara,代码行数:10,代码来源:translate_cache.c


示例19: nv30_sampler_state_create

static void *
nv30_sampler_state_create(struct pipe_context *pipe,
                          const struct pipe_sampler_state *cso)
{
   struct nouveau_object *eng3d = nv30_context(pipe)->screen->eng3d;
   struct nv30_sampler_state *so;
   const float max_lod = 15.0 + (255.0 / 256.0);

   so = MALLOC_STRUCT(nv30_sampler_state);
   if (!so)
      return NULL;

   so->pipe  = *cso;
   so->fmt   = 0;
   so->wrap  = (wrap_mode(cso->wrap_s) << NV30_3D_TEX_WRAP_S__SHIFT) |
               (wrap_mode(cso->wrap_t) << NV30_3D_TEX_WRAP_T__SHIFT) |
               (wrap_mode(cso->wrap_r) << NV30_3D_TEX_WRAP_R__SHIFT);
   so->en    = 0;
   so->wrap |= compare_mode(cso);
   so->filt  = filter_mode(cso) | 0x00002000;
   so->bcol  = (float_to_ubyte(cso->border_color.f[3]) << 24) |
               (float_to_ubyte(cso->border_color.f[0]) << 16) |
               (float_to_ubyte(cso->border_color.f[1]) <<  8) |
               (float_to_ubyte(cso->border_color.f[2]) <<  0);

   if (eng3d->oclass >= NV40_3D_CLASS) {
      unsigned aniso = cso->max_anisotropy;

      if (!cso->normalized_coords)
         so->fmt |= NV40_3D_TEX_FORMAT_RECT;

      if (aniso > 1) {
         if      (aniso >= 16) so->en |= NV40_3D_TEX_ENABLE_ANISO_16X;
         else if (aniso >= 12) so->en |= NV40_3D_TEX_ENABLE_ANISO_12X;
         else if (aniso >= 10) so->en |= NV40_3D_TEX_ENABLE_ANISO_10X;
         else if (aniso >=  8) so->en |= NV40_3D_TEX_ENABLE_ANISO_8X;
         else if (aniso >=  6) so->en |= NV40_3D_TEX_ENABLE_ANISO_6X;
         else if (aniso >=  4) so->en |= NV40_3D_TEX_ENABLE_ANISO_4X;
         else                  so->en |= NV40_3D_TEX_ENABLE_ANISO_2X;

         so->wrap |= nv30_context(pipe)->config.aniso;
      }
   } else {
      so->en |= NV30_3D_TEX_ENABLE_ENABLE;

      if      (cso->max_anisotropy >= 8) so->en |= NV30_3D_TEX_ENABLE_ANISO_8X;
      else if (cso->max_anisotropy >= 4) so->en |= NV30_3D_TEX_ENABLE_ANISO_4X;
      else if (cso->max_anisotropy >= 2) so->en |= NV30_3D_TEX_ENABLE_ANISO_2X;
   }

   so->filt |= (int)(cso->lod_bias * 256.0) & 0x1fff;
   so->max_lod = (int)(CLAMP(cso->max_lod, 0.0, max_lod) * 256.0);
   so->min_lod = (int)(CLAMP(cso->min_lod, 0.0, max_lod) * 256.0);
   return so;
}
开发者ID:UIKit0,项目名称:mesa-1,代码行数:55,代码来源:nv30_texture.c


示例20: nv50_program_create_strmout_state

static struct nv50_stream_output_state *
nv50_program_create_strmout_state(const struct nv50_ir_prog_info *info,
                                  const struct pipe_stream_output_info *pso)
{
   struct nv50_stream_output_state *so;
   unsigned b, i, c;
   unsigned base[4];

   so = MALLOC_STRUCT(nv50_stream_output_state);
   if (!so)
      return NULL;
   memset(so->map, 0xff, sizeof(so->map));

   for (b = 0; b < 4; ++b)
      so->num_attribs[b] = 0;
   for (i = 0; i < pso->num_outputs; ++i) {
      unsigned end =  pso->output[i].dst_offset + pso->output[i].num_components;
      b = pso->output[i].output_buffer;
      assert(b < 4);
      so->num_attribs[b] = MAX2(so->num_attribs[b], end);
   }

   so->ctrl = NV50_3D_STRMOUT_BUFFERS_CTRL_INTERLEAVED;

   so->stride[0] = pso->stride[0] * 4;
   base[0] = 0;
   for (b = 1; b < 4; ++b) {
      assert(!so->num_attribs[b] || so->num_attribs[b] == pso->stride[b]);
      so->stride[b] = so->num_attribs[b] * 4;
      if (so->num_attribs[b])
         so->ctrl = (b + 1) << NV50_3D_STRMOUT_BUFFERS_CTRL_SEPARATE__SHIFT;
      base[b] = align(base[b - 1] + so->num_attribs[b - 1], 4);
   }
   if (so->ctrl & NV50_3D_STRMOUT_BUFFERS_CTRL_INTERLEAVED) {
      assert(so->stride[0] < NV50_3D_STRMOUT_BUFFERS_CTRL_STRIDE__MAX);
      so->ctrl |= so->stride[0] << NV50_3D_STRMOUT_BUFFERS_CTRL_STRIDE__SHIFT;
   }

   so->map_size = base[3] + so->num_attribs[3];

   for (i = 0; i < pso->num_outputs; ++i) {
      const unsigned s = pso->output[i].start_component;
      const unsigned p = pso->output[i].dst_offset;
      const unsigned r = pso->output[i].register_index;
      b = pso->output[i].output_buffer;

      if (r >= info->numOutputs)
         continue;

      for (c = 0; c < pso->output[i].num_components; ++c)
         so->map[base[b] + p + c] = info->out[r].slot[s + c];
   }

   return so;
}
开发者ID:ChristophHaag,项目名称:mesa-mesa,代码行数:55,代码来源:nv50_program.c



注:本文中的MALLOC_STRUCT函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MANGOS_ASSERT函数代码示例发布时间:2022-05-30
下一篇:
C++ MALLOC_CHECK函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap