glsl/linker: Fail to link geometry shader without vertex shader.
authorFabian Bieler <fabianbieler@fastmail.fm>
Fri, 24 May 2013 21:26:54 +0000 (23:26 +0200)
committerPaul Berry <stereotype441@gmail.com>
Fri, 2 Aug 2013 03:23:21 +0000 (20:23 -0700)
From section 2.15 (Geometry Shaders) the OpenGL 3.2 spec:

    A program object that includes a geometry shader must also include
    a vertex shader; otherwise a link error will occur.

Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/linker.cpp

index 4e77a9618c0494eb691d494cd5a833f6dab78192..381440efd59b3eaa954e319a4488ba26e1a1b02f 100644 (file)
@@ -1690,6 +1690,14 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
    prog->Version = max_version;
    prog->IsES = is_es_prog;
 
+   /* Geometry shaders have to be linked with vertex shaders.
+    */
+   if (num_geom_shaders > 0 && num_vert_shaders == 0) {
+      linker_error(prog, "Geometry shader must be linked with "
+                  "vertex shader\n");
+      goto done;
+   }
+
    for (unsigned int i = 0; i < MESA_SHADER_TYPES; i++) {
       if (prog->_LinkedShaders[i] != NULL)
         ctx->Driver.DeleteShader(ctx, prog->_LinkedShaders[i]);