summaryrefslogtreecommitdiffstats
path: root/src/glsl/ast.h
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2015-11-14 15:13:28 +1100
committerTimothy Arceri <[email protected]>2015-11-21 07:28:06 +1100
commit02d2ab23786a0f4ef635914801da97faf577197a (patch)
tree0c69595d3a9353675724b225de41cee8afdd4a7c /src/glsl/ast.h
parent0954b813a3a356b5836f4169783b8c8c58ff2158 (diff)
glsl: add support for complie-time constant expressions
This patch replaces the old interger constant qualifiers with either the new ast_layout_expression type if the qualifier requires merging or ast_expression if the qualifier can't have mulitple declarations or if all but the newest qualifier is simply ignored. We also update the process_qualifier_constant() helper to be similar to the one in the ast_layout_expression class, but in this case it will be used to process the ast_expression qualifiers. Global shader layout qualifier validation is moved out of the parser in this change as we now need to evaluate any constant expression before doing the validation. V2: Fix minimum value check for vertices (Emil) Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/glsl/ast.h')
-rw-r--r--src/glsl/ast.h33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/glsl/ast.h b/src/glsl/ast.h
index ca493401d7c..dfb036dde7e 100644
--- a/src/glsl/ast.h
+++ b/src/glsl/ast.h
@@ -578,7 +578,7 @@ struct ast_type_qualifier {
unsigned precision:2;
/** Geometry shader invocations for GL_ARB_gpu_shader5. */
- int invocations;
+ ast_layout_expression *invocations;
/**
* Location specified via GL_ARB_explicit_attrib_location layout
@@ -586,20 +586,20 @@ struct ast_type_qualifier {
* \note
* This field is only valid if \c explicit_location is set.
*/
- int location;
+ ast_expression *location;
/**
* Index specified via GL_ARB_explicit_attrib_location layout
*
* \note
* This field is only valid if \c explicit_index is set.
*/
- int index;
+ ast_expression *index;
/** Maximum output vertices in GLSL 1.50 geometry shaders. */
- int max_vertices;
+ ast_layout_expression *max_vertices;
/** Stream in GLSL 1.50 geometry shaders. */
- unsigned stream;
+ ast_expression *stream;
/**
* Input or output primitive type in GLSL 1.50 geometry shaders
@@ -613,7 +613,7 @@ struct ast_type_qualifier {
* \note
* This field is only valid if \c explicit_binding is set.
*/
- int binding;
+ ast_expression *binding;
/**
* Offset specified via GL_ARB_shader_atomic_counter's "offset"
@@ -622,14 +622,14 @@ struct ast_type_qualifier {
* \note
* This field is only valid if \c explicit_offset is set.
*/
- int offset;
+ ast_expression *offset;
/**
* Local size specified via GL_ARB_compute_shader's "local_size_{x,y,z}"
* layout qualifier. Element i of this array is only valid if
* flags.q.local_size & (1 << i) is set.
*/
- int local_size[3];
+ ast_layout_expression *local_size[3];
/** Tessellation evaluation shader: vertex spacing (equal, fractional even/odd) */
GLenum vertex_spacing;
@@ -641,7 +641,7 @@ struct ast_type_qualifier {
bool point_mode;
/** Tessellation control shader: number of output vertices */
- int vertices;
+ ast_layout_expression *vertices;
/**
* Image format specified with an ARB_shader_image_load_store
@@ -1113,17 +1113,13 @@ public:
class ast_tcs_output_layout : public ast_node
{
public:
- ast_tcs_output_layout(const struct YYLTYPE &locp, int vertices)
- : vertices(vertices)
+ ast_tcs_output_layout(const struct YYLTYPE &locp)
{
set_location(locp);
}
virtual ir_rvalue *hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state);
-
-private:
- const int vertices;
};
@@ -1155,9 +1151,12 @@ private:
class ast_cs_input_layout : public ast_node
{
public:
- ast_cs_input_layout(const struct YYLTYPE &locp, const unsigned *local_size)
+ ast_cs_input_layout(const struct YYLTYPE &locp,
+ ast_layout_expression **local_size)
{
- memcpy(this->local_size, local_size, sizeof(this->local_size));
+ for (int i = 0; i < 3; i++) {
+ this->local_size[i] = local_size[i];
+ }
set_location(locp);
}
@@ -1165,7 +1164,7 @@ public:
struct _mesa_glsl_parse_state *state);
private:
- unsigned local_size[3];
+ ast_layout_expression *local_size[3];
};
/*@}*/