mesa/sso: Implement _mesa_GenProgramPipelines
authorGregory Hainaut <gregory.hainaut@gmail.com>
Fri, 28 Jun 2013 21:00:13 +0000 (14:00 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 21 Feb 2014 23:41:02 +0000 (15:41 -0800)
Implement GenProgramPipelines based on the VAO code.

This was originally included in another patch, but it was split out by
Ian Romanick.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
src/mesa/main/pipelineobj.c

index 810c6fd1081189d84e38c07568ac687ff1e833ee..9f1cefc883c14720c8da119b662884e977350742 100644 (file)
@@ -285,6 +285,36 @@ _mesa_DeleteProgramPipelines(GLsizei n, const GLuint *pipelines)
 void GLAPIENTRY
 _mesa_GenProgramPipelines(GLsizei n, GLuint *pipelines)
 {
+   GET_CURRENT_CONTEXT(ctx);
+
+   GLuint first;
+   GLint i;
+
+   if (n < 0) {
+      _mesa_error(ctx, GL_INVALID_VALUE, "glGenProgramPipelines(n<0)");
+      return;
+   }
+
+   if (!pipelines) {
+      return;
+   }
+
+   first = _mesa_HashFindFreeKeyBlock(ctx->Pipeline.Objects, n);
+
+   for (i = 0; i < n; i++) {
+      struct gl_pipeline_object *obj;
+      GLuint name = first + i;
+
+      obj = _mesa_new_pipeline_object(ctx, name);
+      if (!obj) {
+         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenProgramPipelines");
+         return;
+      }
+
+      save_pipeline_object(ctx, obj);
+      pipelines[i] = first + i;
+   }
+
 }
 
 /**