~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/mesa/main/remap.c

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
int driDispatchRemapTable[driDispatchRemapTable_size];
53
53
 
54
54
 
55
 
/**
56
 
 * Map a function by its spec.  The function will be added to glapi,
57
 
 * and the dispatch offset will be returned.
58
 
 *
59
 
 * \param spec a '\0'-separated string array specifying a function.
60
 
 *        It begins with the parameter signature of the function,
61
 
 *        followed by the names of the entry points.  An empty entry
62
 
 *        point name terminates the array.
63
 
 *
64
 
 * \return the offset of the (re-)mapped function in the dispatch
65
 
 *         table, or -1.
66
 
 */
67
 
static int
68
 
map_function_spec(const char *spec)
69
 
{
70
 
   const char *signature;
71
 
   const char *names[MAX_ENTRY_POINTS + 1];
72
 
   int num_names = 0;
73
 
 
74
 
   if (!spec)
75
 
      return -1;
76
 
 
77
 
   signature = spec;
78
 
   spec += strlen(spec) + 1;
79
 
 
80
 
   /* spec is terminated by an empty string */
81
 
   while (*spec) {
82
 
      names[num_names] = spec;
83
 
      num_names++;
84
 
      if (num_names >= MAX_ENTRY_POINTS)
85
 
         break;
86
 
      spec += strlen(spec) + 1;
87
 
   }
88
 
   if (!num_names)
89
 
      return -1;
90
 
 
91
 
   names[num_names] = NULL;
92
 
 
93
 
   /* add the entry points to the dispatch table */
94
 
   return _glapi_add_dispatch(names, signature);
95
 
}
96
 
 
97
55
 
98
56
/**
99
57
 * Initialize the remap table.  This is called in one_time_init().
110
68
      return;
111
69
   initialized = true;
112
70
 
113
 
   /* initialize the MESA_remap_table_functions table */
114
71
   for (i = 0; i < driDispatchRemapTable_size; i++) {
115
 
      int offset;
116
 
      const char *spec;
117
 
 
118
72
      /* sanity check */
119
73
      assert(i == MESA_remap_table_functions[i].remap_index);
120
 
      spec = _mesa_function_pool + MESA_remap_table_functions[i].pool_index;
 
74
      const char *name = _mesa_function_pool + MESA_remap_table_functions[i].pool_index;
121
75
 
122
 
      offset = map_function_spec(spec);
123
 
      /* store the dispatch offset in the MESA_remap_table_functions table */
124
 
      driDispatchRemapTable[i] = offset;
125
 
      if (offset < 0) {
126
 
         const char *name = spec + strlen(spec) + 1;
 
76
      /* store the dispatch offset in driDispatchRemapTable, for use by
 
77
       * _gloffset_* macros.
 
78
       */
 
79
      driDispatchRemapTable[i] = _glapi_add_dispatch(name);
 
80
      if (driDispatchRemapTable[i] < 0) {
127
81
         _mesa_warning(NULL, "failed to remap %s", name);
128
82
      }
129
83
   }