glsl: allow bindless samplers/images as vertex shader inputs
[mesa.git] / src / compiler / glsl / linker.cpp
index 7343e4ebe5eb662f8b5056a2e47440390b8b2d82..4dcef2b260e2db93581031ddf0c03d45817d3ba4 100644 (file)
@@ -885,6 +885,13 @@ cross_validate_globals(struct gl_shader_program *prog,
       if (var->type->contains_subroutine())
          continue;
 
+      /* Don't cross validate interface instances. These are only relevant
+       * inside a shader. The cross validation is done at the Interface Block
+       * name level.
+       */
+      if (var->is_interface_instance())
+         continue;
+
       /* Don't cross validate temporaries that are at global scope.  These
        * will eventually get pulled into the shaders 'main'.
        */
@@ -897,11 +904,8 @@ cross_validate_globals(struct gl_shader_program *prog,
        */
       ir_variable *const existing = variables->get_variable(var->name);
       if (existing != NULL) {
-         /* Check if types match. Interface blocks have some special
-          * rules so we handle those elsewhere.
-          */
-         if (var->type != existing->type &&
-             !var->is_interface_instance()) {
+         /* Check if types match. */
+         if (var->type != existing->type) {
             if (!validate_intrastage_arrays(prog, var, existing)) {
                if (var->type->is_record() && existing->type->is_record()
                    && existing->type->record_compare(var->type)) {
@@ -1181,6 +1185,12 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog,
             for (unsigned k = 0; k <= i; k++) {
                delete[] InterfaceBlockStageIndex[k];
             }
+
+            /* Reset the block count. This will help avoid various segfaults
+             * from api calls that assume the array exists due to the count
+             * being non-zero.
+             */
+            *num_blks = 0;
             return false;
          }
 
@@ -3692,8 +3702,7 @@ create_shader_variable(struct gl_shader_program *shProg,
     *        qualifier, except for vertex shader inputs and fragment shader
     *        outputs."
     */
-   if (in->type->base_type == GLSL_TYPE_ATOMIC_UINT ||
-       is_gl_identifier(in->name) ||
+   if (in->type->is_atomic_uint() || is_gl_identifier(in->name) ||
        !(in->data.explicit_location || use_implicit_location)) {
       out->location = -1;
    } else {
@@ -4631,9 +4640,6 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
    bool skip_cache = false;
    if (prog->TransformFeedback.NumVarying > 0) {
       for (unsigned i = 0; i < prog->NumShaders; i++) {
-         if (prog->Shaders[i]->ir) {
-            continue;
-         }
          _mesa_glsl_compile_shader(ctx, prog->Shaders[i], false, false, true);
       }
       skip_cache = true;
@@ -4743,6 +4749,16 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
                       "tessellation evaluation shader\n");
          goto done;
       }
+
+      if (prog->IsES) {
+         if (num_shaders[MESA_SHADER_TESS_EVAL] > 0 &&
+             num_shaders[MESA_SHADER_TESS_CTRL] == 0) {
+            linker_error(prog, "GLSL ES requires non-separable programs "
+                         "containing a tessellation evaluation shader to also "
+                         "be linked with a tessellation control shader\n");
+            goto done;
+         }
+      }
    }
 
    /* Compute shaders have additional restrictions. */