Esempio n. 1
0
static boolean
epilog(
   struct tgsi_iterate_context *iter )
{
   struct sanity_check_ctx *ctx = (struct sanity_check_ctx *) iter;

   /* There must be an END instruction somewhere.
    */
   if (ctx->index_of_END == ~0) {
      report_error( ctx, "Missing END instruction" );
   }

   /* Check if all declared registers were used.
    */
   {
      struct cso_hash_iter iter =
         cso_hash_first_node(ctx->regs_decl);

      while (!cso_hash_iter_is_null(iter)) {
         scan_register *reg = (scan_register *)cso_hash_iter_data(iter);
         if (!is_register_used(ctx, reg) && !is_ind_register_used(ctx, reg)) {
            report_warning( ctx, "%s[%u]: Register never used",
                            file_names[reg->file], reg->indices[0] );
         }
         iter = cso_hash_iter_next(iter);
      }
   }

   /* Print totals, if any.
    */
   if (ctx->errors || ctx->warnings)
      debug_printf( "%u errors, %u warnings\n", ctx->errors, ctx->warnings );

   return TRUE;
}
Esempio n. 2
0
void
util_surfaces_destroy(struct util_surfaces *us, struct pipe_resource *pt, void (*destroy_surface) (struct pipe_surface *))
{
   if(pt->target == PIPE_TEXTURE_3D || pt->target == PIPE_TEXTURE_CUBE)
   {    /* or 2D array */
      if(us->u.hash)
      {
         struct cso_hash_iter iter;
         iter = cso_hash_first_node(us->u.hash);
         while (!cso_hash_iter_is_null(iter)) {
            destroy_surface(cso_hash_iter_data(iter));
            iter = cso_hash_iter_next(iter);
         }

         cso_hash_delete(us->u.hash);
         us->u.hash = NULL;
      }
   }
   else
   {
      if(us->u.array)
      {
         unsigned i;
         for(i = 0; i <= pt->last_level; ++i)
         {
            struct pipe_surface *ps = us->u.array[i];
            if(ps)
               destroy_surface(ps);
         }
         FREE(us->u.array);
         us->u.array = NULL;
      }
   }
}
Esempio n. 3
0
static INLINE void delete_translates(struct translate_cache *cache)
{
   struct cso_hash *hash = cache->hash;
   struct cso_hash_iter iter = cso_hash_first_node(hash);
   while (!cso_hash_iter_is_null(iter)) {
      struct translate *state = (struct translate*)cso_hash_iter_data(iter);
      iter = cso_hash_iter_next(iter);
      if (state) {
         state->release(state);
      }
   }
}
Esempio n. 4
0
struct cso_hash_iter cso_find_state_template(struct cso_cache *sc,
                                             unsigned hash_key, enum cso_cache_type type,
                                             void *templ, unsigned size)
{
   struct cso_hash_iter iter = cso_find_state(sc, hash_key, type);
   while (!cso_hash_iter_is_null(iter)) {
      void *iter_data = cso_hash_iter_data(iter);
      if (!memcmp(iter_data, templ, size))
         return iter;
      iter = cso_hash_iter_next(iter);
   }
   return iter;
}
Esempio n. 5
0
void cso_for_each_state(struct cso_cache *sc, enum cso_cache_type type,
                        cso_state_callback func, void *user_data)
{
   struct cso_hash *hash = _cso_hash_for_type(sc, type);
   struct cso_hash_iter iter;

   iter = cso_hash_first_node(hash);
   while (!cso_hash_iter_is_null(iter)) {
      void *state = cso_hash_iter_data(iter);
      iter = cso_hash_iter_next(iter);
      if (state) {
         func(state, user_data);
      }
   }
}
Esempio n. 6
0
void *cso_hash_find_data_from_template( struct cso_hash *hash,
				        unsigned hash_key, 
				        void *templ,
				        int size )
{
   struct cso_hash_iter iter = cso_hash_find(hash, hash_key);
   while (!cso_hash_iter_is_null(iter)) {
      void *iter_data = cso_hash_iter_data(iter);
      if (!memcmp(iter_data, templ, size)) {
	 /* We found a match
	  */
         return iter_data;
      }
      iter = cso_hash_iter_next(iter);
   }
   return NULL;
}
Esempio n. 7
0
static boolean
is_any_register_declared(
   struct sanity_check_ctx *ctx,
   uint file )
{
   struct cso_hash_iter iter =
      cso_hash_first_node(ctx->regs_decl);

   while (!cso_hash_iter_is_null(iter)) {
      scan_register *reg = (scan_register *)cso_hash_iter_data(iter);
      if (reg->file == file)
         return TRUE;
      iter = cso_hash_iter_next(iter);
   }

   return FALSE;
}
Esempio n. 8
0
static INLINE struct cso_hash_iter
hash_table_find_iter(const struct keymap *map, const void *key,
                     unsigned key_hash)
{
   struct cso_hash_iter iter;
   struct keymap_item *item;
   
   iter = cso_hash_find(map->cso, key_hash);
   while (!cso_hash_iter_is_null(iter)) {
      item = (struct keymap_item *) cso_hash_iter_data(iter);
      if (!memcmp(item->key, key, map->key_size))
         break;
      iter = cso_hash_iter_next(iter);
   }
   
   return iter;
}
Esempio n. 9
0
void font_destroy(struct vg_font *font)
{
   struct vg_context *ctx = vg_current_context();
   struct cso_hash_iter iter;

   vg_context_remove_object(ctx, &font->base);

   iter = cso_hash_first_node(font->glyphs);
   while (!cso_hash_iter_is_null(iter)) {
      struct vg_glyph *glyph = (struct vg_glyph *) cso_hash_iter_data(iter);
      FREE(glyph);
      iter = cso_hash_iter_next(iter);
   }
   cso_hash_delete(font->glyphs);

   vg_free_object(&font->base);

   FREE(font);
}
Esempio n. 10
0
void cso_for_each_state(struct cso_cache *sc, enum cso_cache_type type,
                        cso_state_callback func, void *user_data)
{
   struct cso_hash *hash = 0;
   struct cso_hash_iter iter;

   switch (type) {
   case CSO_BLEND:
      hash = sc->blend_hash;
      break;
   case CSO_SAMPLER:
      hash = sc->sampler_hash;
      break;
   case CSO_DEPTH_STENCIL_ALPHA:
      hash = sc->depth_stencil_hash;
      break;
   case CSO_RASTERIZER:
      hash = sc->rasterizer_hash;
      break;
   case CSO_FRAGMENT_SHADER:
      hash = sc->fs_hash;
      break;
   case CSO_VERTEX_SHADER:
      hash = sc->vs_hash;
      break;
   case CSO_VELEMENTS:
      hash = sc->velements_hash;
      break;
   }

   iter = cso_hash_first_node(hash);
   while (!cso_hash_iter_is_null(iter)) {
      void *state = cso_hash_iter_data(iter);
      iter = cso_hash_iter_next(iter);
      if (state) {
         func(state, user_data);
      }
   }
}
Esempio n. 11
0
static INLINE void sanitize_hash(struct cso_hash *hash, enum cso_cache_type type,
                                 int max_size, void *user_data)
{
   struct cso_context *ctx = (struct cso_context *)user_data;
   /* if we're approach the maximum size, remove fourth of the entries
    * otherwise every subsequent call will go through the same */
   int hash_size = cso_hash_size(hash);
   int max_entries = (max_size > hash_size) ? max_size : hash_size;
   int to_remove =  (max_size < max_entries) * max_entries/4;
   struct cso_hash_iter iter = cso_hash_first_node(hash);
   if (hash_size > max_size)
      to_remove += hash_size - max_size;
   while (to_remove) {
      /*remove elements until we're good */
      /*fixme: currently we pick the nodes to remove at random*/
      void *cso = cso_hash_iter_data(iter);
      if (delete_cso(ctx, cso, type)) {
         iter = cso_hash_erase(hash, iter);
         --to_remove;
      } else
         iter = cso_hash_iter_next(iter);
   }
}