summaryrefslogtreecommitdiffstats
path: root/src/glsl/ast_to_hir.cpp
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2015-11-14 14:32:38 +1100
committerTimothy Arceri <[email protected]>2015-11-21 07:27:21 +1100
commitdb3c36aedfa2e92c2cf1c17a096c1b5e7cd51c42 (patch)
tree3cf1511c52d8db589f0bf1ac4ba0103112db8999 /src/glsl/ast_to_hir.cpp
parent17e224e8ec9c190fb856a60a22d8e19b8f20837e (diff)
glsl: move stream layout max validation
This validation is moved later so we can validate the max value when compile time constant support is added in a later patch. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/glsl/ast_to_hir.cpp')
-rw-r--r--src/glsl/ast_to_hir.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 7104aa0a633..bb0db7992e5 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2522,6 +2522,21 @@ process_qualifier_constant(struct _mesa_glsl_parse_state *state,
}
static bool
+validate_stream_qualifier(YYLTYPE *loc, struct _mesa_glsl_parse_state *state,
+ unsigned stream)
+{
+ if (stream >= state->ctx->Const.MaxVertexStreams) {
+ _mesa_glsl_error(loc, state,
+ "invalid stream specified %d is larger than "
+ "MAX_VERTEX_STREAMS - 1 (%d).",
+ stream, state->ctx->Const.MaxVertexStreams - 1);
+ return false;
+ }
+
+ return true;
+}
+
+static bool
validate_binding_qualifier(struct _mesa_glsl_parse_state *state,
YYLTYPE *loc,
const glsl_type *type,
@@ -3036,7 +3051,8 @@ apply_layout_qualifier_to_variable(const struct ast_type_qualifier *qual,
qual->flags.q.out && qual->flags.q.stream) {
unsigned qual_stream;
if (process_qualifier_constant(state, loc, "stream", qual->stream,
- &qual_stream)) {
+ &qual_stream) &&
+ validate_stream_qualifier(loc, state, qual_stream)) {
var->data.stream = qual_stream;
}
}
@@ -6517,7 +6533,8 @@ ast_interface_block::hir(exec_list *instructions,
unsigned qual_stream;
if (!process_qualifier_constant(state, &loc, "stream", this->layout.stream,
- &qual_stream)) {
+ &qual_stream) ||
+ !validate_stream_qualifier(&loc, state, qual_stream)) {
/* If the stream qualifier is invalid it doesn't make sense to continue
* on and try to compare stream layouts on member variables against it
* so just return early.