[Mesa-dev,30/46] glsl: relax unsized input/output block arrays for TCS/TES

Submitted by Marek Olšák on June 16, 2015, 11:01 p.m.

Details

Message ID 1434495702-27901-30-git-send-email-maraeo@gmail.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Marek Olšák June 16, 2015, 11:01 p.m.
From: Chris Forbes <chrisf@ijw.co.nz>

---
 src/glsl/ast_to_hir.cpp | 33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 837bac7..fb957a1 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -5938,16 +5938,35 @@  ast_interface_block::hir(exec_list *instructions,
           *     geometry shader inputs. All other input and output block
           *     arrays must specify an array size.
           *
+          * The same applies to tessellation shaders.
+          *
           * The upshot of this is that the only circumstance where an
           * interface array size *doesn't* need to be specified is on a
-          * geometry shader input.
+          * geometry shader input, tessellation control shader input,
+          * tessellation control shader output, and tessellation evaluation
+          * shader input.
           */
-         if (this->array_specifier->is_unsized_array &&
-             (state->stage != MESA_SHADER_GEOMETRY || !this->layout.flags.q.in)) {
-            _mesa_glsl_error(&loc, state,
-                             "only geometry shader inputs may be unsized "
-                             "instance block arrays");
-
+         if (this->array_specifier->is_unsized_array) {
+            bool allow_inputs = state->stage == MESA_SHADER_GEOMETRY ||
+                                state->stage == MESA_SHADER_TESS_CTRL ||
+                                state->stage == MESA_SHADER_TESS_EVAL;
+            bool allow_outputs = state->stage == MESA_SHADER_TESS_CTRL;
+
+            if (this->layout.flags.q.in) {
+               if (!allow_inputs)
+                  _mesa_glsl_error(&loc, state,
+                                   "unsized input block arrays not allowed in this "
+                                   "shader stage");
+            } else if (this->layout.flags.q.out) {
+               if (!allow_outputs)
+                  _mesa_glsl_error(&loc, state,
+                                   "unsized output block arrays not allowed in this "
+                                   "shader stage");
+            } else {
+               /* by elimination, this is a uniform block array */
+               _mesa_glsl_error(&loc, state,
+                                "unsized uniform block arrays not allowed");
+            }
          }
 
          const glsl_type *block_array_type =

Comments

This should use

_mesa_shader_stage_to_string

in the _mesa_glsl_error strings,

Change that and it can have
Reviewed-by: Dave Airlie <airlied@redhat.com>
>
> ---
>  src/glsl/ast_to_hir.cpp | 33 ++++++++++++++++++++++++++-------
>  1 file changed, 26 insertions(+), 7 deletions(-)
>
> diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
> index 837bac7..fb957a1 100644
> --- a/src/glsl/ast_to_hir.cpp
> +++ b/src/glsl/ast_to_hir.cpp
> @@ -5938,16 +5938,35 @@ ast_interface_block::hir(exec_list *instructions,
>            *     geometry shader inputs. All other input and output block
>            *     arrays must specify an array size.
>            *
> +          * The same applies to tessellation shaders.
> +          *
>            * The upshot of this is that the only circumstance where an
>            * interface array size *doesn't* need to be specified is on a
> -          * geometry shader input.
> +          * geometry shader input, tessellation control shader input,
> +          * tessellation control shader output, and tessellation evaluation
> +          * shader input.
>            */
> -         if (this->array_specifier->is_unsized_array &&
> -             (state->stage != MESA_SHADER_GEOMETRY || !this->layout.flags.q.in)) {
> -            _mesa_glsl_error(&loc, state,
> -                             "only geometry shader inputs may be unsized "
> -                             "instance block arrays");
> -
> +         if (this->array_specifier->is_unsized_array) {
> +            bool allow_inputs = state->stage == MESA_SHADER_GEOMETRY ||
> +                                state->stage == MESA_SHADER_TESS_CTRL ||
> +                                state->stage == MESA_SHADER_TESS_EVAL;
> +            bool allow_outputs = state->stage == MESA_SHADER_TESS_CTRL;
> +
> +            if (this->layout.flags.q.in) {
> +               if (!allow_inputs)
> +                  _mesa_glsl_error(&loc, state,
> +                                   "unsized input block arrays not allowed in this "
> +                                   "shader stage");
> +            } else if (this->layout.flags.q.out) {
> +               if (!allow_outputs)
> +                  _mesa_glsl_error(&loc, state,
> +                                   "unsized output block arrays not allowed in this "
> +                                   "shader stage");
> +            } else {
> +               /* by elimination, this is a uniform block array */
> +               _mesa_glsl_error(&loc, state,
> +                                "unsized uniform block arrays not allowed");
> +            }
>           }
>
>           const glsl_type *block_array_type =
> --
> 2.1.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev