[Mesa-dev] [PATCH 21/34] glsl/linker: Fail to link geometry shader without vertex shader.

Paul Berry stereotype441 at gmail.com
Sun Jul 28 23:03:47 PDT 2013


From: Fabian Bieler <fabianbieler at fastmail.fm>

>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 at gmail.com>
---
 src/glsl/linker.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index d43d0f2..0c8449e 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1804,6 +1804,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]);
-- 
1.8.3.4



More information about the mesa-dev mailing list