static void
create_samplers(struct gl_context *ctx, GLsizei count, GLuint *samplers,
                const char *caller)
{
   GLuint first;
   GLint i;

   if (!samplers)
      return;

   _mesa_HashLockMutex(ctx->Shared->SamplerObjects);

   first = _mesa_HashFindFreeKeyBlock(ctx->Shared->SamplerObjects, count);

   /* Insert the ID and pointer to new sampler object into hash table */
   for (i = 0; i < count; i++) {
      struct gl_sampler_object *sampObj;
      GLuint name = first + i;

      sampObj = ctx->Driver.NewSamplerObject(ctx, name);
      if (!sampObj) {
         _mesa_HashUnlockMutex(ctx->Shared->SamplerObjects);
         _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", caller);
         return;
      }

      _mesa_HashInsertLocked(ctx->Shared->SamplerObjects, name, sampObj);
      samplers[i] = name;
   }

   _mesa_HashUnlockMutex(ctx->Shared->SamplerObjects);
}
Beispiel #2
0
/**
 * Generate a list of new program identifiers.
 * \note Not compiled into display lists.
 * \note Called by both glGenProgramsNV and glGenProgramsARB.
 */
void GLAPIENTRY
_mesa_GenProgramsARB(GLsizei n, GLuint *ids)
{
   GLuint first;
   GLuint i;
   GET_CURRENT_CONTEXT(ctx);

   if (n < 0) {
      _mesa_error(ctx, GL_INVALID_VALUE, "glGenPrograms");
      return;
   }

   if (!ids)
      return;

   _mesa_HashLockMutex(ctx->Shared->Programs);

   first = _mesa_HashFindFreeKeyBlock(ctx->Shared->Programs, n);

   /* Insert pointer to dummy program as placeholder */
   for (i = 0; i < (GLuint) n; i++) {
      _mesa_HashInsertLocked(ctx->Shared->Programs, first + i,
                             &_mesa_DummyProgram);
   }

   _mesa_HashUnlockMutex(ctx->Shared->Programs);

   /* Return the program names */
   for (i = 0; i < (GLuint) n; i++) {
      ids[i] = first + i;
   }
}