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++; }
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; } }
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; }
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; }
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; }
/** * 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; }
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; }
/** * 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); }
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; } }
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; }
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; } }
struct dynfn *tnl_makeX86Attr3f( TNLcontext *tnl, int key ) { static char temp[] = { 0xba, 0x78, 0x56, 0x34, 0x12, /* mov $DEST,%edx */ 0x8b, 0x44, 0x24, 0x04, /* mov 0x4(%esp,1),%eax */ 0x89, 0x02, /* mov %eax,(%edx) */ 0x8b, 0x44, 0x24, 0x08, /* mov 0x8(%esp,1),%eax */ 0x89, 0x42, 0x04, /* mov %eax,0x4(%edx) */ 0x8b, 0x44, 0x24, 0x0c, /* mov 0xc(%esp,1),%eax */ 0x89, 0x42, 0x08, /* mov %eax,0x8(%edx) */ 0xc3, /* ret */ }; struct dynfn *dfn = MALLOC_STRUCT( dynfn ); if (TNL_DEBUG & DEBUG_CODEGEN) _mesa_debug(NULL, "%s 0x%08x\n", __FUNCTION__, key ); insert_at_head( &tnl->dfn_cache.Normal3f, dfn ); dfn->key = key; dfn->code = ALIGN_MALLOC( sizeof(temp), 16 ); memcpy (dfn->code, temp, sizeof(temp)); FIXUP(dfn->code, 1, 0x12345678, (int)tnl->normalptr); return dfn; }
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; }
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; }
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; } }
/* * 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; }
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; }
/** * 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; }
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; }
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; }
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; }
/** * Allocate and initialize a new buffer object. * * Default callback for the \c dd_function_table::NewBufferObject() hook. */ static struct gl_buffer_object * _mesa_new_buffer_object( GLcontext *ctx, GLuint name, GLenum target ) { struct gl_buffer_object *obj; (void) ctx; obj = MALLOC_STRUCT(gl_buffer_object); _mesa_initialize_buffer_object(obj, name, target); return obj; }
static void vbo_minmax_cache_store(struct gl_context *ctx, struct gl_buffer_object *bufferObj, GLenum type, GLintptr offset, GLuint count, GLuint min, GLuint max) { struct minmax_cache_entry *entry; struct hash_entry *table_entry; uint32_t hash; if (!vbo_use_minmax_cache(bufferObj)) return; mtx_lock(&bufferObj->Mutex); if (!bufferObj->MinMaxCache) { bufferObj->MinMaxCache = _mesa_hash_table_create(NULL, (uint32_t (*)(const void *))vbo_minmax_cache_hash, (bool (*)(const void *, const void *))vbo_minmax_cache_key_equal); if (!bufferObj->MinMaxCache) goto out; } entry = MALLOC_STRUCT(minmax_cache_entry); if (!entry) goto out; entry->key.offset = offset; entry->key.count = count; entry->key.type = type; entry->min = min; entry->max = max; hash = vbo_minmax_cache_hash(&entry->key); table_entry = _mesa_hash_table_search_pre_hashed(bufferObj->MinMaxCache, hash, &entry->key); if (table_entry) { /* It seems like this could happen when two contexts are rendering using * the same buffer object from multiple threads. */ _mesa_debug(ctx, "duplicate entry in minmax cache\n"); free(entry); goto out; } table_entry = _mesa_hash_table_insert_pre_hashed(bufferObj->MinMaxCache, hash, &entry->key, entry); if (!table_entry) free(entry); out: mtx_unlock(&bufferObj->Mutex); }
static struct dynfn *radeon_makeSSEAttribute2f( struct dynfn * cache, int key, const char * name, void * dest ) { struct dynfn *dfn = MALLOC_STRUCT( dynfn ); if (RADEON_DEBUG & DEBUG_CODEGEN) fprintf(stderr, "%s 0x%08x\n", name, key ); DFN ( _sse_Attribute2f, (*cache) ); FIXUP(dfn->code, 8, 0x0, (int)dest); return dfn; }
CallTempStructNode* NewNode(CallTempStructNode* pPrevious) { //printf("### Creating new temp node...\n"); CallTempStructNode* pNode = MALLOC_STRUCT(CallTempStructNode); memset(pNode, 0, sizeof(CallTempStructNode)); InitCallTempStruct(&pNode->fCallTempStruct); //pNode->fCallTempStruct.vm = dcNewCallVM(1024); if (pPrevious) { pPrevious->fNext = pNode; pNode->fPrevious = pPrevious; } return pNode; }
HASHTAB *make_hashtab (int index) { HASHTAB *tab; int size = primes[index]; tab = MALLOC_STRUCT (HASHTAB); /* Current maximum size (i.e. number of entries) of hash table: */ tab->size = size; /* This reflects the number of items currently held by the hash table: */ tab->nr_items = 0; /* This counts the number of times an insert of an item is done, i.e. number of times `lookup (,,, INSERT)' is called. */ tab->nr_inserts = 0; /* We count as collisions the fact that when an item has to be inserted the entry at its hash index is occupied by a different one. Subsequent tries to resolve this collision are not counted as new collisions. Merely looking up an item will never increase the collision count. */ tab->nr_collisions = 0; /* Number of rehashes undertaken for this table: */ tab->nr_rehashes = 0; /* Current index in primes table: */ tab->primes_index = index; #ifdef ALLOW_REHASH /* Function called when non-NULL to process change of entry when rehashing in process. */ tab->rehash_function = 0; #ifdef USE_SHADOW { register int i; register int *p; tab->shadow_free_index = 0; tab->shadow_table = MALLOC_ARRAY (size, int); for (i = 0, p = tab->shadow_table; i < size; i++) *p++ = NOT_PRESENT; } #endif #endif /* Allocate an array of empty entries: */ tab->entries = CALLOC_ARRAY (size, HASHTAB_ENTRY_PTR); return tab; }
/** * 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(GLcontext *ctx, GLuint id) { struct gl_query_object *q = MALLOC_STRUCT(gl_query_object); if (q) { q->Id = id; q->Result = 0; q->Active = GL_FALSE; q->Ready = GL_TRUE; /* correct, see spec */ } return q; }
struct dynfn *r200_makeX86Normal3f( 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] ); DFN ( _x86_Normal3f, rmesa->vb.dfn_cache.Normal3f ); FIXUP(dfn->code, 1, 0x12345678, (int)vb.normalptr); return dfn; }
struct dynfn *tnl_makeX86Vertex2f( TNLcontext *tnl, int key ) { struct dynfn *dfn = MALLOC_STRUCT( dynfn ); if (RADEON_DEBUG & DEBUG_CODEGEN) _mesa_debug(NULL, "%s 0x%08x\n", __FUNCTION__, key ); switch (tnl->vertex_size) { default: { /* Repz convenient as it's possible to emit code for any size * vertex with little tweaking. Might as well read vertsize * though, and have only one of these. */ static char temp[] = { 0x57, /* push %edi */ 0x56, /* push %esi */ 0xbe, 0, 0, 0, 0, /* mov $VERTEX+2,%esi */ 0x8b, 0x3d, 0, 0, 0, 0, /* mov DMAPTR,%edi */ 0x8b, 0x44, 0x24, 0x0c, /* mov 0x0c(%esp,1),%eax */ 0x8b, 0x54, 0x24, 0x10, /* mov 0x10(%esp,1),%edx */ 0x89, 0x07, /* mov %eax,(%edi) */ 0x89, 0x57, 0x04, /* mov %edx,0x4(%edi) */ 0x83, 0xc7, 0x08, /* add $0x8,%edi */ 0xb9, 0, 0, 0, 0, /* mov $VERTSIZE-2,%ecx */ 0xf3, 0xa5, /* repz movsl %ds:(%esi),%es:(%edi)*/ 0xa1, 0, 0, 0, 0, /* mov COUNTER,%eax */ 0x89, 0x3d, 0, 0, 0, 0, /* mov %edi,DMAPTR */ 0x48, /* dec %eax */ 0xa3, 0, 0, 0, 0, /* mov %eax,COUNTER */ 0x5e, /* pop %esi */ 0x5f, /* pop %edi */ 0x74, 0x01, /* je +1 */ 0xc3, /* ret */ 0xff, 0x25, 0, 0, 0, 0 /* jmp NOTIFY */ }; dfn->code = ALIGN_MALLOC( sizeof(temp), 16 ); memcpy (dfn->code, temp, sizeof(temp)); FIXUP(dfn->code, 3, 0x0, (int)&tnl->vertex[2]); FIXUP(dfn->code, 9, 0x0, (int)&tnl->dmaptr); FIXUP(dfn->code, 37, 0x0, tnl->vertex_size-2); FIXUP(dfn->code, 44, 0x0, (int)&tnl->counter); FIXUP(dfn->code, 50, 0x0, (int)&tnl->dmaptr); FIXUP(dfn->code, 56, 0x0, (int)&tnl->counter); FIXUP(dfn->code, 67, 0x0, (int)&tnl->notify); break; } } insert_at_head( &tnl->dfn_cache.Vertex3f, dfn ); dfn->key = key; return dfn; }
struct dynfn *r200_makeX86TexCoord2fv( 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 0x%08x\n", __FUNCTION__, key[0], key[1] ); DFN ( _x86_TexCoord2fv, rmesa->vb.dfn_cache.TexCoord2fv ); FIXUP(dfn->code, 5, 0x12345678, (int)vb.texcoordptr[0]); return dfn; }