#include "glsl_parser_extras.h"
#include "ast.h"
#include "compiler/glsl_types.h"
-#include "program/hash_table.h"
+#include "util/hash_table.h"
#include "main/macros.h"
#include "main/shaderobj.h"
#include "ir.h"
#include "ir_builder.h"
+#include "builtin_functions.h"
using namespace ir_builder;
static void
detect_conflicting_assignments(struct _mesa_glsl_parse_state *state,
- exec_list *instructions);
+ exec_list *instructions);
static void
remove_per_vertex_blocks(exec_list *instructions,
_mesa_glsl_parse_state *state, ir_variable_mode mode);
return visit_continue;
ir_variable *var = ir->variable_referenced();
- /* We can have image_write_only set on both images and buffer variables,
+ /* We can have memory_write_only set on both images and buffer variables,
* but in the former there is a distinction between reads from
* the variable itself (write_only) and from the memory they point to
- * (image_write_only), while in the case of buffer variables there is
+ * (memory_write_only), while in the case of buffer variables there is
* no such distinction, that is why this check here is limited to
* buffer variables alone.
*/
if (!var || var->data.mode != ir_var_shader_storage)
return visit_continue;
- if (var->data.image_write_only) {
+ if (var->data.memory_write_only) {
found = var;
return visit_stop;
}
case GLSL_TYPE_INT: return ir_unop_i2d;
case GLSL_TYPE_UINT: return ir_unop_u2d;
case GLSL_TYPE_FLOAT: return ir_unop_f2d;
+ case GLSL_TYPE_INT64: return ir_unop_i642d;
+ case GLSL_TYPE_UINT64: return ir_unop_u642d;
+ default: return (ir_expression_operation)0;
+ }
+
+ case GLSL_TYPE_UINT64:
+ if (!state->has_int64())
+ return (ir_expression_operation)0;
+ switch (from->base_type) {
+ case GLSL_TYPE_INT: return ir_unop_i2u64;
+ case GLSL_TYPE_UINT: return ir_unop_u2u64;
+ case GLSL_TYPE_INT64: return ir_unop_i642u64;
+ default: return (ir_expression_operation)0;
+ }
+
+ case GLSL_TYPE_INT64:
+ if (!state->has_int64())
+ return (ir_expression_operation)0;
+ switch (from->base_type) {
+ case GLSL_TYPE_INT: return ir_unop_i2i64;
default: return (ir_expression_operation)0;
}
* If a conversion is possible (or unnecessary), \c true is returned.
* Otherwise \c false is returned.
*/
-bool
+static bool
apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from,
struct _mesa_glsl_parse_state *state)
{
* type of both operands must be float.
*/
assert(type_a->is_matrix() || type_b->is_matrix());
- assert(type_a->base_type == GLSL_TYPE_FLOAT ||
- type_a->base_type == GLSL_TYPE_DOUBLE);
- assert(type_b->base_type == GLSL_TYPE_FLOAT ||
- type_b->base_type == GLSL_TYPE_DOUBLE);
+ assert(type_a->is_float() || type_a->is_double());
+ assert(type_b->is_float() || type_b->is_double());
/* "* The operator is add (+), subtract (-), or divide (/), and the
* operands are matrices with the same number of rows and the same
* (|). The operands must be of type signed or unsigned integers or
* integer vectors."
*/
- if (!type_a->is_integer()) {
+ if (!type_a->is_integer_32_64()) {
_mesa_glsl_error(loc, state, "LHS of `%s' must be an integer",
ast_expression::operator_string(op));
return glsl_type::error_type;
}
- if (!type_b->is_integer()) {
+ if (!type_b->is_integer_32_64()) {
_mesa_glsl_error(loc, state, "RHS of `%s' must be an integer",
ast_expression::operator_string(op));
return glsl_type::error_type;
* "The operator modulus (%) operates on signed or unsigned integers or
* integer vectors."
*/
- if (!type_a->is_integer()) {
+ if (!type_a->is_integer_32_64()) {
_mesa_glsl_error(loc, state, "LHS of operator %% must be an integer");
return glsl_type::error_type;
}
- if (!type_b->is_integer()) {
+ if (!type_b->is_integer_32_64()) {
_mesa_glsl_error(loc, state, "RHS of operator %% must be an integer");
return glsl_type::error_type;
}
* must be signed or unsigned integers or integer vectors. One operand
* can be signed while the other is unsigned."
*/
- if (!type_a->is_integer()) {
+ if (!type_a->is_integer_32_64()) {
_mesa_glsl_error(loc, state, "LHS of operator %s must be an integer or "
"integer vector", ast_expression::operator_string(op));
return glsl_type::error_type;
/* Check for implicit conversion in GLSL 1.20 */
if (apply_implicit_conversion(lhs->type, rhs, state)) {
if (rhs->type == lhs->type)
- return rhs;
+ return rhs;
}
_mesa_glsl_error(&loc, state,
error_emitted = true;
} else if (lhs_var != NULL && (lhs_var->data.read_only ||
(lhs_var->data.mode == ir_var_shader_storage &&
- lhs_var->data.image_read_only))) {
- /* We can have image_read_only set on both images and buffer variables,
+ lhs_var->data.memory_read_only))) {
+ /* We can have memory_read_only set on both images and buffer variables,
* but in the former there is a distinction between assignments to
* the variable itself (read_only) and to the memory they point to
- * (image_read_only), while in the case of buffer variables there is
+ * (memory_read_only), while in the case of buffer variables there is
* no such distinction, that is why this check here is limited to
* buffer variables alone.
*/
* i = j += 1;
*/
if (needs_rvalue) {
- ir_variable *var = new(ctx) ir_variable(rhs->type, "assignment_tmp",
- ir_var_temporary);
- instructions->push_tail(var);
- instructions->push_tail(assign(var, rhs));
-
+ ir_rvalue *rvalue;
if (!error_emitted) {
- ir_dereference_variable *deref_var = new(ctx) ir_dereference_variable(var);
+ ir_variable *var = new(ctx) ir_variable(rhs->type, "assignment_tmp",
+ ir_var_temporary);
+ instructions->push_tail(var);
+ instructions->push_tail(assign(var, rhs));
+
+ ir_dereference_variable *deref_var =
+ new(ctx) ir_dereference_variable(var);
instructions->push_tail(new(ctx) ir_assignment(lhs, deref_var));
+ rvalue = new(ctx) ir_dereference_variable(var);
+ } else {
+ rvalue = ir_rvalue::error_value(ctx);
}
- ir_rvalue *rvalue = new(ctx) ir_dereference_variable(var);
-
*out_rvalue = rvalue;
} else {
if (!error_emitted)
ir_variable *var;
var = new(ctx) ir_variable(lvalue->type, "_post_incdec_tmp",
- ir_var_temporary);
+ ir_var_temporary);
instructions->push_tail(var);
instructions->push_tail(new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var),
- lvalue));
+ lvalue));
return new(ctx) ir_dereference_variable(var);
}
case GLSL_TYPE_INT:
case GLSL_TYPE_BOOL:
case GLSL_TYPE_DOUBLE:
+ case GLSL_TYPE_UINT64:
+ case GLSL_TYPE_INT64:
return new(mem_ctx) ir_expression(operation, op0, op1);
case GLSL_TYPE_ARRAY: {
*/
ir_rvalue *
get_scalar_boolean_operand(exec_list *instructions,
- struct _mesa_glsl_parse_state *state,
- ast_expression *parent_expr,
- int operand,
- const char *operand_name,
- bool *error_emitted)
+ struct _mesa_glsl_parse_state *state,
+ ast_expression *parent_expr,
+ int operand,
+ const char *operand_name,
+ bool *error_emitted)
{
ast_expression *expr = parent_expr->subexpressions[operand];
void *ctx = state;
return new(ctx) ir_constant((unsigned) 1);
case GLSL_TYPE_INT:
return new(ctx) ir_constant(1);
+ case GLSL_TYPE_UINT64:
+ return new(ctx) ir_constant((uint64_t) 1);
+ case GLSL_TYPE_INT64:
+ return new(ctx) ir_constant((int64_t) 1);
default:
case GLSL_TYPE_FLOAT:
return new(ctx) ir_constant(1.0f);
-1, /* ast_float_constant doesn't conv to ir_expression. */
-1, /* ast_bool_constant doesn't conv to ir_expression. */
-1, /* ast_sequence doesn't convert to ir_expression. */
+ -1, /* ast_aggregate shouldn't ever even get here. */
};
ir_rvalue *result = NULL;
ir_rvalue *op[3];
- const struct glsl_type *type; /* a temporary variable for switch cases */
+ const struct glsl_type *type, *orig_type;
bool error_emitted = false;
YYLTYPE loc;
* in a scalar boolean. See page 57 of the GLSL 1.50 spec.
*/
assert(type->is_error()
- || ((type->base_type == GLSL_TYPE_BOOL)
- && type->is_scalar()));
+ || (type->is_boolean() && type->is_scalar()));
result = new(ctx) ir_expression(operations[this->oper], type,
op[0], op[1]);
error_emitted = true;
}
- if (!op[0]->type->is_integer()) {
+ if (!op[0]->type->is_integer_32_64()) {
_mesa_glsl_error(&loc, state, "operand of `~' must be an integer");
error_emitted = true;
}
op[0] = this->subexpressions[0]->hir(instructions, state);
op[1] = this->subexpressions[1]->hir(instructions, state);
+ orig_type = op[0]->type;
type = arithmetic_result_type(op[0], op[1],
(this->oper == ast_mul_assign),
state, & loc);
+ if (type != orig_type) {
+ _mesa_glsl_error(& loc, state,
+ "could not implicitly convert "
+ "%s to %s", type->name, orig_type->name);
+ type = glsl_type::error_type;
+ }
+
ir_rvalue *temp_rhs = new(ctx) ir_expression(operations[this->oper], type,
op[0], op[1]);
op[0] = this->subexpressions[0]->hir(instructions, state);
op[1] = this->subexpressions[1]->hir(instructions, state);
+ orig_type = op[0]->type;
type = modulus_result_type(op[0], op[1], state, &loc);
+ if (type != orig_type) {
+ _mesa_glsl_error(& loc, state,
+ "could not implicitly convert "
+ "%s to %s", type->name, orig_type->name);
+ type = glsl_type::error_type;
+ }
+
assert(operations[this->oper] == ir_binop_mod);
ir_rvalue *temp_rhs;
this->subexpressions[0]->set_is_lhs(true);
op[0] = this->subexpressions[0]->hir(instructions, state);
op[1] = this->subexpressions[1]->hir(instructions, state);
+
+ orig_type = op[0]->type;
type = bit_logic_result_type(op[0], op[1], this->oper, state, &loc);
+
+ if (type != orig_type) {
+ _mesa_glsl_error(& loc, state,
+ "could not implicitly convert "
+ "%s to %s", type->name, orig_type->name);
+ type = glsl_type::error_type;
+ }
+
ir_rvalue *temp_rhs = new(ctx) ir_expression(operations[this->oper],
type, op[0], op[1]);
error_emitted =
result = new(ctx) ir_constant(this->primary_expression.double_constant);
break;
+ case ast_uint64_constant:
+ result = new(ctx) ir_constant(this->primary_expression.uint64_constant);
+ break;
+
+ case ast_int64_constant:
+ result = new(ctx) ir_constant(this->primary_expression.int64_constant);
+ break;
+
case ast_sequence: {
/* It should not be possible to generate a sequence in the AST without
* any expressions in it.
case ast_float_constant:
case ast_bool_constant:
case ast_double_constant:
+ case ast_int64_constant:
+ case ast_uint64_constant:
return false;
case ast_aggregate:
case GLSL_TYPE_SAMPLER: {
const unsigned type_idx =
type->sampler_array + 2 * type->sampler_shadow;
- const unsigned offset = type->base_type == GLSL_TYPE_SAMPLER ? 0 : 4;
+ const unsigned offset = type->is_sampler() ? 0 : 4;
assert(type_idx < 4);
switch (type->sampled_type) {
case GLSL_TYPE_FLOAT:
switch (type->sampler_dimensionality) {
case GLSL_SAMPLER_DIM_1D: {
- assert(type->base_type == GLSL_TYPE_SAMPLER);
+ assert(type->is_sampler());
static const char *const names[4] = {
"sampler1D", "sampler1DArray",
"sampler1DShadow", "sampler1DArrayShadow"
return names[offset + type_idx];
}
case GLSL_SAMPLER_DIM_MS: {
- assert(type->base_type == GLSL_TYPE_SAMPLER);
+ assert(type->is_sampler());
static const char *const names[4] = {
"sampler2DMS", "sampler2DMSArray", NULL, NULL
};
return names[type_idx];
}
case GLSL_SAMPLER_DIM_RECT: {
- assert(type->base_type == GLSL_TYPE_SAMPLER);
+ assert(type->is_sampler());
static const char *const names[4] = {
"samplerRect", NULL, "samplerRectShadow", NULL
};
return names[offset + type_idx];
}
case GLSL_SAMPLER_DIM_EXTERNAL: {
- assert(type->base_type == GLSL_TYPE_SAMPLER);
+ assert(type->is_sampler());
static const char *const names[4] = {
"samplerExternalOES", NULL, NULL, NULL
};
case GLSL_TYPE_INT:
switch (type->sampler_dimensionality) {
case GLSL_SAMPLER_DIM_1D: {
- assert(type->base_type == GLSL_TYPE_SAMPLER);
+ assert(type->is_sampler());
static const char *const names[4] = {
"isampler1D", "isampler1DArray", NULL, NULL
};
return names[offset + type_idx];
}
case GLSL_SAMPLER_DIM_MS: {
- assert(type->base_type == GLSL_TYPE_SAMPLER);
+ assert(type->is_sampler());
static const char *const names[4] = {
"isampler2DMS", "isampler2DMSArray", NULL, NULL
};
return names[type_idx];
}
case GLSL_SAMPLER_DIM_RECT: {
- assert(type->base_type == GLSL_TYPE_SAMPLER);
+ assert(type->is_sampler());
static const char *const names[4] = {
"isamplerRect", NULL, "isamplerRectShadow", NULL
};
case GLSL_TYPE_UINT:
switch (type->sampler_dimensionality) {
case GLSL_SAMPLER_DIM_1D: {
- assert(type->base_type == GLSL_TYPE_SAMPLER);
+ assert(type->is_sampler());
static const char *const names[4] = {
"usampler1D", "usampler1DArray", NULL, NULL
};
return names[offset + type_idx];
}
case GLSL_SAMPLER_DIM_MS: {
- assert(type->base_type == GLSL_TYPE_SAMPLER);
+ assert(type->is_sampler());
static const char *const names[4] = {
"usampler2DMS", "usampler2DMSArray", NULL, NULL
};
return names[type_idx];
}
case GLSL_SAMPLER_DIM_RECT: {
- assert(type->base_type == GLSL_TYPE_SAMPLER);
+ assert(type->is_sampler());
static const char *const names[4] = {
"usamplerRect", NULL, "usamplerRectShadow", NULL
};
type->name);
}
}
+
+
+ /* Section 4.1.7.3 (Atomic Counters) of the GLSL ES 3.10 spec says:
+ *
+ * "The default precision of all atomic types is highp. It is an error to
+ * declare an atomic type with a different precision or to specify the
+ * default precision for an atomic type to be lowp or mediump."
+ */
+ if (type->is_atomic_uint() && precision != ast_precision_high) {
+ _mesa_glsl_error(loc, state,
+ "atomic_uint can only have highp precision qualifier");
+ }
+
return precision;
}
}
}
+static bool
+is_allowed_invariant(ir_variable *var, struct _mesa_glsl_parse_state *state)
+{
+ if (is_varying_var(var, state->stage))
+ return true;
+
+ /* From Section 4.6.1 ("The Invariant Qualifier") GLSL 1.20 spec:
+ * "Only variables output from a vertex shader can be candidates
+ * for invariance".
+ */
+ if (!state->is_version(130, 0))
+ return false;
+
+ /*
+ * Later specs remove this language - so allowed invariant
+ * on fragment shader outputs as well.
+ */
+ if (state->stage == MESA_SHADER_FRAGMENT &&
+ var->data.mode == ir_var_shader_out)
+ return true;
+ return false;
+}
/**
* Matrix layout qualifiers are only allowed on certain types
assert(ctx->Const.MaxAtomicBufferBindings <= MAX_COMBINED_ATOMIC_BUFFERS);
if (qual_binding >= ctx->Const.MaxAtomicBufferBindings) {
_mesa_glsl_error(loc, state, "layout(binding = %d) exceeds the "
- " maximum number of atomic counter buffer bindings"
+ "maximum number of atomic counter buffer bindings "
"(%u)", qual_binding,
ctx->Const.MaxAtomicBufferBindings);
assert(ctx->Const.MaxImageUnits <= MAX_IMAGE_UNITS);
if (max_index >= ctx->Const.MaxImageUnits) {
_mesa_glsl_error(loc, state, "Image binding %d exceeds the "
- " maximum number of image units (%d)", max_index,
+ "maximum number of image units (%d)", max_index,
ctx->Const.MaxImageUnits);
return;
}
} else {
_mesa_glsl_error(loc, state,
"the \"binding\" qualifier only applies to uniform "
- "blocks, opaque variables, or arrays thereof");
+ "blocks, storage blocks, opaque variables, or arrays "
+ "thereof");
return;
}
return;
}
+static void
+validate_fragment_flat_interpolation_input(struct _mesa_glsl_parse_state *state,
+ YYLTYPE *loc,
+ const glsl_interp_mode interpolation,
+ const struct glsl_type *var_type,
+ ir_variable_mode mode)
+{
+ if (state->stage != MESA_SHADER_FRAGMENT ||
+ interpolation == INTERP_MODE_FLAT ||
+ mode != ir_var_shader_in)
+ return;
+
+ /* Integer fragment inputs must be qualified with 'flat'. In GLSL ES,
+ * so must integer vertex outputs.
+ *
+ * From section 4.3.4 ("Inputs") of the GLSL 1.50 spec:
+ * "Fragment shader inputs that are signed or unsigned integers or
+ * integer vectors must be qualified with the interpolation qualifier
+ * flat."
+ *
+ * From section 4.3.4 ("Input Variables") of the GLSL 3.00 ES spec:
+ * "Fragment shader inputs that are, or contain, signed or unsigned
+ * integers or integer vectors must be qualified with the
+ * interpolation qualifier flat."
+ *
+ * From section 4.3.6 ("Output Variables") of the GLSL 3.00 ES spec:
+ * "Vertex shader outputs that are, or contain, signed or unsigned
+ * integers or integer vectors must be qualified with the
+ * interpolation qualifier flat."
+ *
+ * Note that prior to GLSL 1.50, this requirement applied to vertex
+ * outputs rather than fragment inputs. That creates problems in the
+ * presence of geometry shaders, so we adopt the GLSL 1.50 rule for all
+ * desktop GL shaders. For GLSL ES shaders, we follow the spec and
+ * apply the restriction to both vertex outputs and fragment inputs.
+ *
+ * Note also that the desktop GLSL specs are missing the text "or
+ * contain"; this is presumably an oversight, since there is no
+ * reasonable way to interpolate a fragment shader input that contains
+ * an integer. See Khronos bug #15671.
+ */
+ if (state->is_version(130, 300)
+ && var_type->contains_integer()) {
+ _mesa_glsl_error(loc, state, "if a fragment input is (or contains) "
+ "an integer, then it must be qualified with 'flat'");
+ }
+
+ /* Double fragment inputs must be qualified with 'flat'.
+ *
+ * From the "Overview" of the ARB_gpu_shader_fp64 extension spec:
+ * "This extension does not support interpolation of double-precision
+ * values; doubles used as fragment shader inputs must be qualified as
+ * "flat"."
+ *
+ * From section 4.3.4 ("Inputs") of the GLSL 4.00 spec:
+ * "Fragment shader inputs that are signed or unsigned integers, integer
+ * vectors, or any double-precision floating-point type must be
+ * qualified with the interpolation qualifier flat."
+ *
+ * Note that the GLSL specs are missing the text "or contain"; this is
+ * presumably an oversight. See Khronos bug #15671.
+ *
+ * The 'double' type does not exist in GLSL ES so far.
+ */
+ if (state->has_double()
+ && var_type->contains_double()) {
+ _mesa_glsl_error(loc, state, "if a fragment input is (or contains) "
+ "a double, then it must be qualified with 'flat'");
+ }
+}
static void
validate_interpolation_qualifier(struct _mesa_glsl_parse_state *state,
"deprecated storage qualifier '%s'", i, s);
}
- /* Integer fragment inputs must be qualified with 'flat'. In GLSL ES,
- * so must integer vertex outputs.
- *
- * From section 4.3.4 ("Inputs") of the GLSL 1.50 spec:
- * "Fragment shader inputs that are signed or unsigned integers or
- * integer vectors must be qualified with the interpolation qualifier
- * flat."
- *
- * From section 4.3.4 ("Input Variables") of the GLSL 3.00 ES spec:
- * "Fragment shader inputs that are, or contain, signed or unsigned
- * integers or integer vectors must be qualified with the
- * interpolation qualifier flat."
- *
- * From section 4.3.6 ("Output Variables") of the GLSL 3.00 ES spec:
- * "Vertex shader outputs that are, or contain, signed or unsigned
- * integers or integer vectors must be qualified with the
- * interpolation qualifier flat."
- *
- * Note that prior to GLSL 1.50, this requirement applied to vertex
- * outputs rather than fragment inputs. That creates problems in the
- * presence of geometry shaders, so we adopt the GLSL 1.50 rule for all
- * desktop GL shaders. For GLSL ES shaders, we follow the spec and
- * apply the restriction to both vertex outputs and fragment inputs.
- *
- * Note also that the desktop GLSL specs are missing the text "or
- * contain"; this is presumably an oversight, since there is no
- * reasonable way to interpolate a fragment shader input that contains
- * an integer. See Khronos bug #15671.
- */
- if (state->is_version(130, 300)
- && var_type->contains_integer()
- && interpolation != INTERP_MODE_FLAT
- && ((state->stage == MESA_SHADER_FRAGMENT && mode == ir_var_shader_in)
- || (state->stage == MESA_SHADER_VERTEX && mode == ir_var_shader_out
- && state->es_shader))) {
- const char *shader_var_type = (state->stage == MESA_SHADER_VERTEX) ?
- "vertex output" : "fragment input";
- _mesa_glsl_error(loc, state, "if a %s is (or contains) "
- "an integer, then it must be qualified with 'flat'",
- shader_var_type);
- }
-
- /* Double fragment inputs must be qualified with 'flat'.
- *
- * From the "Overview" of the ARB_gpu_shader_fp64 extension spec:
- * "This extension does not support interpolation of double-precision
- * values; doubles used as fragment shader inputs must be qualified as
- * "flat"."
- *
- * From section 4.3.4 ("Inputs") of the GLSL 4.00 spec:
- * "Fragment shader inputs that are signed or unsigned integers, integer
- * vectors, or any double-precision floating-point type must be
- * qualified with the interpolation qualifier flat."
- *
- * Note that the GLSL specs are missing the text "or contain"; this is
- * presumably an oversight. See Khronos bug #15671.
- *
- * The 'double' type does not exist in GLSL ES so far.
- */
- if (state->has_double()
- && var_type->contains_double()
- && interpolation != INTERP_MODE_FLAT
- && state->stage == MESA_SHADER_FRAGMENT
- && mode == ir_var_shader_in) {
- _mesa_glsl_error(loc, state, "if a fragment input is (or contains) "
- "a double, then it must be qualified with 'flat'");
- }
+ validate_fragment_flat_interpolation_input(state, loc, interpolation,
+ var_type, mode);
}
static glsl_interp_mode
}
/* Check if index was set for the uniform instead of the function */
- if (qual->flags.q.explicit_index && qual->flags.q.subroutine) {
+ if (qual->flags.q.explicit_index && qual->is_subroutine_decl()) {
_mesa_glsl_error(loc, state, "an index qualifier can only be "
"used with subroutine functions");
return;
}
}
+static bool
+validate_storage_for_sampler_image_types(ir_variable *var,
+ struct _mesa_glsl_parse_state *state,
+ YYLTYPE *loc)
+{
+ /* From section 4.1.7 of the GLSL 4.40 spec:
+ *
+ * "[Opaque types] can only be declared as function
+ * parameters or uniform-qualified variables."
+ *
+ * From section 4.1.7 of the ARB_bindless_texture spec:
+ *
+ * "Samplers may be declared as shader inputs and outputs, as uniform
+ * variables, as temporary variables, and as function parameters."
+ *
+ * From section 4.1.X of the ARB_bindless_texture spec:
+ *
+ * "Images may be declared as shader inputs and outputs, as uniform
+ * variables, as temporary variables, and as function parameters."
+ */
+ if (state->has_bindless()) {
+ if (var->data.mode != ir_var_auto &&
+ var->data.mode != ir_var_uniform &&
+ var->data.mode != ir_var_shader_in &&
+ var->data.mode != ir_var_shader_out &&
+ var->data.mode != ir_var_function_in &&
+ var->data.mode != ir_var_function_out &&
+ var->data.mode != ir_var_function_inout) {
+ _mesa_glsl_error(loc, state, "bindless image/sampler variables may "
+ "only be declared as shader inputs and outputs, as "
+ "uniform variables, as temporary variables and as "
+ "function parameters");
+ return false;
+ }
+ } else {
+ if (var->data.mode != ir_var_uniform &&
+ var->data.mode != ir_var_function_in) {
+ _mesa_glsl_error(loc, state, "image/sampler variables may only be "
+ "declared as function parameters or "
+ "uniform-qualified global variables");
+ return false;
+ }
+ }
+ return true;
+}
+
+static bool
+validate_memory_qualifier_for_type(struct _mesa_glsl_parse_state *state,
+ YYLTYPE *loc,
+ const struct ast_type_qualifier *qual,
+ const glsl_type *type)
+{
+ /* From Section 4.10 (Memory Qualifiers) of the GLSL 4.50 spec:
+ *
+ * "Memory qualifiers are only supported in the declarations of image
+ * variables, buffer variables, and shader storage blocks; it is an error
+ * to use such qualifiers in any other declarations.
+ */
+ if (!type->is_image() && !qual->flags.q.buffer) {
+ if (qual->flags.q.read_only ||
+ qual->flags.q.write_only ||
+ qual->flags.q.coherent ||
+ qual->flags.q._volatile ||
+ qual->flags.q.restrict_flag) {
+ _mesa_glsl_error(loc, state, "memory qualifiers may only be applied "
+ "in the declarations of image variables, buffer "
+ "variables, and shader storage blocks");
+ return false;
+ }
+ }
+ return true;
+}
+
+static bool
+validate_image_format_qualifier_for_type(struct _mesa_glsl_parse_state *state,
+ YYLTYPE *loc,
+ const struct ast_type_qualifier *qual,
+ const glsl_type *type)
+{
+ /* From section 4.4.6.2 (Format Layout Qualifiers) of the GLSL 4.50 spec:
+ *
+ * "Format layout qualifiers can be used on image variable declarations
+ * (those declared with a basic type having “image ” in its keyword)."
+ */
+ if (!type->is_image() && qual->flags.q.explicit_image_format) {
+ _mesa_glsl_error(loc, state, "format layout qualifiers may only be "
+ "applied to images");
+ return false;
+ }
+ return true;
+}
+
static void
apply_image_qualifier_to_variable(const struct ast_type_qualifier *qual,
ir_variable *var,
{
const glsl_type *base_type = var->type->without_array();
- if (base_type->is_image()) {
- if (var->data.mode != ir_var_uniform &&
- var->data.mode != ir_var_function_in) {
- _mesa_glsl_error(loc, state, "image variables may only be declared as "
- "function parameters or uniform-qualified "
- "global variables");
- }
+ if (!validate_image_format_qualifier_for_type(state, loc, qual, base_type) ||
+ !validate_memory_qualifier_for_type(state, loc, qual, base_type))
+ return;
- var->data.image_read_only |= qual->flags.q.read_only;
- var->data.image_write_only |= qual->flags.q.write_only;
- var->data.image_coherent |= qual->flags.q.coherent;
- var->data.image_volatile |= qual->flags.q._volatile;
- var->data.image_restrict |= qual->flags.q.restrict_flag;
- var->data.read_only = true;
+ if (!base_type->is_image())
+ return;
- if (qual->flags.q.explicit_image_format) {
- if (var->data.mode == ir_var_function_in) {
- _mesa_glsl_error(loc, state, "format qualifiers cannot be "
- "used on image function parameters");
- }
+ if (!validate_storage_for_sampler_image_types(var, state, loc))
+ return;
- if (qual->image_base_type != base_type->sampled_type) {
- _mesa_glsl_error(loc, state, "format qualifier doesn't match the "
- "base data type of the image");
- }
+ var->data.memory_read_only |= qual->flags.q.read_only;
+ var->data.memory_write_only |= qual->flags.q.write_only;
+ var->data.memory_coherent |= qual->flags.q.coherent;
+ var->data.memory_volatile |= qual->flags.q._volatile;
+ var->data.memory_restrict |= qual->flags.q.restrict_flag;
- var->data.image_format = qual->image_format;
- } else {
- if (var->data.mode == ir_var_uniform) {
- if (state->es_shader) {
- _mesa_glsl_error(loc, state, "all image uniforms "
- "must have a format layout qualifier");
+ if (qual->flags.q.explicit_image_format) {
+ if (var->data.mode == ir_var_function_in) {
+ _mesa_glsl_error(loc, state, "format qualifiers cannot be used on "
+ "image function parameters");
+ }
- } else if (!qual->flags.q.write_only) {
- _mesa_glsl_error(loc, state, "image uniforms not qualified with "
- "`writeonly' must have a format layout "
- "qualifier");
- }
- }
+ if (qual->image_base_type != base_type->sampled_type) {
+ _mesa_glsl_error(loc, state, "format qualifier doesn't match the base "
+ "data type of the image");
+ }
- var->data.image_format = GL_NONE;
+ var->data.image_format = qual->image_format;
+ } else {
+ if (var->data.mode == ir_var_uniform) {
+ if (state->es_shader) {
+ _mesa_glsl_error(loc, state, "all image uniforms must have a "
+ "format layout qualifier");
+ } else if (!qual->flags.q.write_only) {
+ _mesa_glsl_error(loc, state, "image uniforms not qualified with "
+ "`writeonly' must have a format layout qualifier");
+ }
}
+ var->data.image_format = GL_NONE;
+ }
- /* From page 70 of the GLSL ES 3.1 specification:
- *
- * "Except for image variables qualified with the format qualifiers
- * r32f, r32i, and r32ui, image variables must specify either memory
- * qualifier readonly or the memory qualifier writeonly."
- */
- if (state->es_shader &&
- var->data.image_format != GL_R32F &&
- var->data.image_format != GL_R32I &&
- var->data.image_format != GL_R32UI &&
- !var->data.image_read_only &&
- !var->data.image_write_only) {
- _mesa_glsl_error(loc, state, "image variables of format other than "
- "r32f, r32i or r32ui must be qualified `readonly' or "
- "`writeonly'");
- }
-
- } else if (qual->flags.q.read_only ||
- qual->flags.q.write_only ||
- qual->flags.q.coherent ||
- qual->flags.q._volatile ||
- qual->flags.q.restrict_flag ||
- qual->flags.q.explicit_image_format) {
- _mesa_glsl_error(loc, state, "memory qualifiers may only be applied to "
- "images");
+ /* From page 70 of the GLSL ES 3.1 specification:
+ *
+ * "Except for image variables qualified with the format qualifiers r32f,
+ * r32i, and r32ui, image variables must specify either memory qualifier
+ * readonly or the memory qualifier writeonly."
+ */
+ if (state->es_shader &&
+ var->data.image_format != GL_R32F &&
+ var->data.image_format != GL_R32I &&
+ var->data.image_format != GL_R32UI &&
+ !var->data.memory_read_only &&
+ !var->data.memory_write_only) {
+ _mesa_glsl_error(loc, state, "image variables of format other than r32f, "
+ "r32i or r32ui must be qualified `readonly' or "
+ "`writeonly'");
}
}
}
}
+static void
+apply_bindless_qualifier_to_variable(const struct ast_type_qualifier *qual,
+ ir_variable *var,
+ struct _mesa_glsl_parse_state *state,
+ YYLTYPE *loc)
+{
+ bool has_local_qualifiers = qual->flags.q.bindless_sampler ||
+ qual->flags.q.bindless_image ||
+ qual->flags.q.bound_sampler ||
+ qual->flags.q.bound_image;
+
+ /* The ARB_bindless_texture spec says:
+ *
+ * "Modify Section 4.4.6 Opaque-Uniform Layout Qualifiers of the GLSL 4.30
+ * spec"
+ *
+ * "If these layout qualifiers are applied to other types of default block
+ * uniforms, or variables with non-uniform storage, a compile-time error
+ * will be generated."
+ */
+ if (has_local_qualifiers && !qual->flags.q.uniform) {
+ _mesa_glsl_error(loc, state, "ARB_bindless_texture layout qualifiers "
+ "can only be applied to default block uniforms or "
+ "variables with uniform storage");
+ return;
+ }
+
+ /* The ARB_bindless_texture spec doesn't state anything in this situation,
+ * but it makes sense to only allow bindless_sampler/bound_sampler for
+ * sampler types, and respectively bindless_image/bound_image for image
+ * types.
+ */
+ if ((qual->flags.q.bindless_sampler || qual->flags.q.bound_sampler) &&
+ !var->type->contains_sampler()) {
+ _mesa_glsl_error(loc, state, "bindless_sampler or bound_sampler can only "
+ "be applied to sampler types");
+ return;
+ }
+
+ if ((qual->flags.q.bindless_image || qual->flags.q.bound_image) &&
+ !var->type->contains_image()) {
+ _mesa_glsl_error(loc, state, "bindless_image or bound_image can only be "
+ "applied to image types");
+ return;
+ }
+
+ /* The bindless_sampler/bindless_image (and respectively
+ * bound_sampler/bound_image) layout qualifiers can be set at global and at
+ * local scope.
+ */
+ if (var->type->contains_sampler() || var->type->contains_image()) {
+ var->data.bindless = qual->flags.q.bindless_sampler ||
+ qual->flags.q.bindless_image ||
+ state->bindless_sampler_specified ||
+ state->bindless_image_specified;
+
+ var->data.bound = qual->flags.q.bound_sampler ||
+ qual->flags.q.bound_image ||
+ state->bound_sampler_specified ||
+ state->bound_image_specified;
+ }
+}
+
static void
apply_layout_qualifier_to_variable(const struct ast_type_qualifier *qual,
ir_variable *var,
? "origin_upper_left" : "pixel_center_integer";
_mesa_glsl_error(loc, state,
- "layout qualifier `%s' can only be applied to "
- "fragment shader input `gl_FragCoord'",
- qual_string);
+ "layout qualifier `%s' can only be applied to "
+ "fragment shader input `gl_FragCoord'",
+ qual_string);
}
if (qual->flags.q.explicit_location) {
}
}
} else if (qual->flags.q.explicit_index) {
- if (!qual->flags.q.subroutine_def)
+ if (!qual->subroutine_list)
_mesa_glsl_error(loc, state,
"explicit index requires explicit location");
} else if (qual->flags.q.explicit_component) {
}
}
+ if (var->type->contains_sampler() &&
+ !validate_storage_for_sampler_image_types(var, state, loc))
+ return;
+
/* Is the 'layout' keyword used with parameters that allow relaxed checking.
* Many implementations of GL_ARB_fragment_coord_conventions_enable and some
* implementations (only Mesa?) GL_ARB_explicit_attrib_location_enable
/* Layout qualifiers for gl_FragDepth, which are enabled by extension
* AMD_conservative_depth.
*/
- int depth_layout_count = qual->flags.q.depth_any
- + qual->flags.q.depth_greater
- + qual->flags.q.depth_less
- + qual->flags.q.depth_unchanged;
- if (depth_layout_count > 0
+ if (qual->flags.q.depth_type
&& !state->is_version(420, 0)
&& !state->AMD_conservative_depth_enable
&& !state->ARB_conservative_depth_enable) {
"extension GL_AMD_conservative_depth or "
"GL_ARB_conservative_depth must be enabled "
"to use depth layout qualifiers");
- } else if (depth_layout_count > 0
+ } else if (qual->flags.q.depth_type
&& strcmp(var->name, "gl_FragDepth") != 0) {
_mesa_glsl_error(loc, state,
"depth layout qualifiers can be applied only to "
"gl_FragDepth");
- } else if (depth_layout_count > 1
- && strcmp(var->name, "gl_FragDepth") == 0) {
- _mesa_glsl_error(loc, state,
- "at most one depth layout qualifier can be applied to "
- "gl_FragDepth");
}
- if (qual->flags.q.depth_any)
+
+ switch (qual->depth_type) {
+ case ast_depth_any:
var->data.depth_layout = ir_depth_layout_any;
- else if (qual->flags.q.depth_greater)
+ break;
+ case ast_depth_greater:
var->data.depth_layout = ir_depth_layout_greater;
- else if (qual->flags.q.depth_less)
+ break;
+ case ast_depth_less:
var->data.depth_layout = ir_depth_layout_less;
- else if (qual->flags.q.depth_unchanged)
- var->data.depth_layout = ir_depth_layout_unchanged;
- else
- var->data.depth_layout = ir_depth_layout_none;
+ break;
+ case ast_depth_unchanged:
+ var->data.depth_layout = ir_depth_layout_unchanged;
+ break;
+ default:
+ var->data.depth_layout = ir_depth_layout_none;
+ break;
+ }
if (qual->flags.q.std140 ||
qual->flags.q.std430 ||
_mesa_glsl_error(loc, state, "early_fragment_tests layout qualifier only "
"valid in fragment shader input layout declaration.");
}
+
+ if (qual->flags.q.inner_coverage) {
+ _mesa_glsl_error(loc, state, "inner_coverage layout qualifier only "
+ "valid in fragment shader input layout declaration.");
+ }
+
+ if (qual->flags.q.post_depth_coverage) {
+ _mesa_glsl_error(loc, state, "post_depth_coverage layout qualifier only "
+ "valid in fragment shader input layout declaration.");
+ }
+
+ if (state->has_bindless())
+ apply_bindless_qualifier_to_variable(qual, var, state, loc);
}
static void
}
}
- if (qual->flags.q.subroutine && !qual->flags.q.uniform) {
+ if (qual->is_subroutine_decl() && !qual->flags.q.uniform) {
_mesa_glsl_error(loc, state,
"`subroutine' may only be applied to uniforms, "
"subroutine type declarations, or function definitions");
*/
assert(var->data.mode != ir_var_temporary);
if (qual->flags.q.in && qual->flags.q.out)
- var->data.mode = ir_var_function_inout;
+ var->data.mode = is_parameter ? ir_var_function_inout : ir_var_shader_out;
else if (qual->flags.q.in)
var->data.mode = is_parameter ? ir_var_function_in : ir_var_shader_in;
else if (qual->flags.q.attribute
- || (qual->flags.q.varying && (state->stage == MESA_SHADER_FRAGMENT)))
+ || (qual->flags.q.varying && (state->stage == MESA_SHADER_FRAGMENT)))
var->data.mode = ir_var_shader_in;
else if (qual->flags.q.out)
var->data.mode = is_parameter ? ir_var_function_out : ir_var_shader_out;
else if (qual->flags.q.shared_storage)
var->data.mode = ir_var_shader_shared;
+ var->data.fb_fetch_output = state->stage == MESA_SHADER_FRAGMENT &&
+ qual->flags.q.in && qual->flags.q.out;
+
if (!is_parameter && is_varying_var(var, state->stage)) {
/* User-defined ins/outs are not permitted in compute shaders. */
if (state->stage == MESA_SHADER_COMPUTE) {
* 3.00 spec allows structs as well. Varying structs are also allowed
* in GLSL 1.50.
*/
- switch (var->type->get_scalar_type()->base_type) {
+ switch (var->type->without_array()->base_type) {
case GLSL_TYPE_FLOAT:
/* Ok in all GLSL versions */
break;
"varying variables may not be of type struct");
break;
case GLSL_TYPE_DOUBLE:
+ case GLSL_TYPE_UINT64:
+ case GLSL_TYPE_INT64:
break;
default:
_mesa_glsl_error(loc, state, "illegal type for a varying variable");
}
/**
- * Get the variable that is being redeclared by this declaration
+ * Get the variable that is being redeclared by this declaration or if it
+ * does not exist, the current declared variable.
*
* Semantic checks to verify the validity of the redeclaration are also
* performed. If semantic checks fail, compilation error will be emitted via
*
* \returns
* A pointer to an existing variable in the current scope if the declaration
- * is a redeclaration, \c NULL otherwise.
+ * is a redeclaration, current variable otherwise. \c is_declared boolean
+ * will return \c true if the declaration is a redeclaration, \c false
+ * otherwise.
*/
static ir_variable *
get_variable_being_redeclared(ir_variable *var, YYLTYPE loc,
struct _mesa_glsl_parse_state *state,
- bool allow_all_redeclarations)
+ bool allow_all_redeclarations,
+ bool *is_redeclaration)
{
/* Check if this declaration is actually a re-declaration, either to
* resize an array or add qualifiers to an existing variable.
if (earlier == NULL ||
(state->current_function != NULL &&
!state->symbols->name_declared_this_scope(var->name))) {
- return NULL;
+ *is_redeclaration = false;
+ return var;
}
+ *is_redeclaration = true;
/* From page 24 (page 30 of the PDF) of the GLSL 1.50 spec,
*
earlier->data.depth_layout = var->data.depth_layout;
+ } else if (state->has_framebuffer_fetch() &&
+ strcmp(var->name, "gl_LastFragData") == 0 &&
+ var->type == earlier->type &&
+ var->data.mode == ir_var_auto) {
+ /* According to the EXT_shader_framebuffer_fetch spec:
+ *
+ * "By default, gl_LastFragData is declared with the mediump precision
+ * qualifier. This can be changed by redeclaring the corresponding
+ * variables with the desired precision qualifier."
+ */
+ earlier->data.precision = var->data.precision;
+
} else if (allow_all_redeclarations) {
if (earlier->data.mode != var->data.mode) {
_mesa_glsl_error(&loc, state,
*/
ir_rvalue *
process_initializer(ir_variable *var, ast_declaration *decl,
- ast_fully_specified_type *type,
- exec_list *initializer_instructions,
- struct _mesa_glsl_parse_state *state)
+ ast_fully_specified_type *type,
+ exec_list *initializer_instructions,
+ struct _mesa_glsl_parse_state *state)
{
ir_rvalue *result = NULL;
if (var->data.patch)
return;
- /* Unsized arrays are implicitly sized to gl_MaxPatchVertices. */
+ /* The ARB_tessellation_shader spec says:
+ *
+ * "Declaring an array size is optional. If no size is specified, it
+ * will be taken from the implementation-dependent maximum patch size
+ * (gl_MaxPatchVertices). If a size is specified, it must match the
+ * maximum patch size; otherwise, a compile or link error will occur."
+ *
+ * This text appears twice, once for TCS inputs, and again for TES inputs.
+ */
if (var->type->is_unsized_array()) {
var->type = glsl_type::get_array_instance(var->type->fields.array,
state->Const.MaxPatchVertices);
+ } else if (var->type->length != state->Const.MaxPatchVertices) {
+ _mesa_glsl_error(&loc, state,
+ "per-vertex tessellation shader input arrays must be "
+ "sized to gl_MaxPatchVertices (%d).",
+ state->Const.MaxPatchVertices);
}
}
_mesa_glsl_error(& loc, state,
"undeclared variable `%s' cannot be marked "
"invariant", decl->identifier);
- } else if (!is_varying_var(earlier, state->stage)) {
+ } else if (!is_allowed_invariant(earlier, state)) {
_mesa_glsl_error(&loc, state,
"`%s' cannot be marked invariant; interfaces between "
"shader stages only.", decl->identifier);
allowed_atomic_qual_mask.flags.q.explicit_offset = 1;
allowed_atomic_qual_mask.flags.q.uniform = 1;
- type->qualifier.validate_flags(&loc, state,
- "invalid layout qualifier for "
- "atomic_uint",
- allowed_atomic_qual_mask);
+ type->qualifier.validate_flags(&loc, state, allowed_atomic_qual_mask,
+ "invalid layout qualifier for",
+ "atomic_uint");
}
if (this->declarations.is_empty()) {
* confusing error.
*/
assert(this->type->specifier->structure == NULL || decl_type != NULL
- || state->error);
+ || state->error);
if (decl_type == NULL) {
_mesa_glsl_error(&loc, state,
"invalid type `%s' in empty declaration",
type_name);
} else {
- if (decl_type->base_type == GLSL_TYPE_ARRAY) {
+ if (decl_type->is_array()) {
/* From Section 13.22 (Array Declarations) of the GLSL ES 3.2
* spec:
*
validate_array_dimensions(decl_type, state, &loc);
}
- if (decl_type->base_type == GLSL_TYPE_ATOMIC_UINT) {
+ if (decl_type->is_atomic_uint()) {
/* Empty atomic counter declarations are allowed and useful
* to set the default offset qualifier.
*/
continue;
}
- if (this->type->qualifier.flags.q.subroutine) {
+ if (this->type->qualifier.is_subroutine_decl()) {
const glsl_type *t;
const char *name;
}
apply_type_qualifier_to_variable(& this->type->qualifier, var, state,
- & loc, false);
+ & loc, false);
apply_layout_qualifier_to_variable(&this->type->qualifier, var, state,
&loc);
if ((var->data.mode == ir_var_auto || var->data.mode == ir_var_temporary)
&& (var->type->is_numeric() || var->type->is_boolean())
&& state->zero_init) {
- const ir_constant_data data = {0};
+ const ir_constant_data data = { { 0 } };
var->data.has_initializer = true;
var->constant_initializer = new(var) ir_constant(var->type, &data);
}
if (this->type->qualifier.flags.q.invariant) {
- if (!is_varying_var(var, state->stage)) {
+ if (!is_allowed_invariant(var, state)) {
_mesa_glsl_error(&loc, state,
"`%s' cannot be marked invariant; interfaces between "
"shader stages only", var->name);
*/
if (this->type->qualifier.flags.q.attribute) {
mode = "attribute";
- } else if (this->type->qualifier.flags.q.subroutine) {
+ } else if (this->type->qualifier.is_subroutine_decl()) {
mode = "subroutine uniform";
} else if (this->type->qualifier.flags.q.uniform) {
mode = "uniform";
switch (check_type->base_type) {
case GLSL_TYPE_FLOAT:
break;
+ case GLSL_TYPE_UINT64:
+ case GLSL_TYPE_INT64:
+ break;
case GLSL_TYPE_UINT:
case GLSL_TYPE_INT:
if (state->is_version(120, 300))
break;
case GLSL_TYPE_DOUBLE:
- if (check_type->base_type == GLSL_TYPE_DOUBLE && (state->is_version(410, 0) || state->ARB_vertex_attrib_64bit_enable))
+ if (check_type->is_double() && (state->is_version(410, 0) || state->ARB_vertex_attrib_64bit_enable))
break;
/* FALLTHROUGH */
default:
} else if (var->data.mode == ir_var_shader_out) {
const glsl_type *check_type = var->type->without_array();
- /* From section 4.3.6 (Output variables) of the GLSL 4.40 spec:
- *
- * It is a compile-time error to declare a vertex, tessellation
- * evaluation, tessellation control, or geometry shader output
- * that contains any of the following:
- *
- * * A Boolean type (bool, bvec2 ...)
- * * An opaque type
- */
- if (check_type->is_boolean() || check_type->contains_opaque())
- _mesa_glsl_error(&loc, state,
- "%s shader output cannot have type %s",
- _mesa_shader_stage_to_string(state->stage),
- check_type->name);
-
/* From section 4.3.6 (Output variables) of the GLSL 4.40 spec:
*
* It is a compile-time error to declare a fragment shader output
* * A matrix
* * A structure
* * An array of array
+ *
+ * ES 3.20 updates this to apply to tessellation and geometry shaders
+ * as well. Because there are per-vertex arrays in the new stages,
+ * it strikes the "array of..." rules and replaces them with these:
+ *
+ * * For per-vertex-arrayed variables (applies to tessellation
+ * control, tessellation evaluation and geometry shaders):
+ *
+ * * Per-vertex-arrayed arrays of arrays
+ * * Per-vertex-arrayed arrays of structures
+ *
+ * * For non-per-vertex-arrayed variables:
+ *
+ * * An array of arrays
+ * * An array of structures
+ *
+ * which basically says to unwrap the per-vertex aspect and apply
+ * the old rules.
*/
if (state->es_shader) {
if (var->type->is_array() &&
"cannot have an array of arrays",
_mesa_shader_stage_to_string(state->stage));
}
- if (state->stage == MESA_SHADER_VERTEX) {
- if (var->type->is_array() &&
- var->type->fields.array->is_record()) {
+ if (state->stage <= MESA_SHADER_GEOMETRY) {
+ const glsl_type *type = var->type;
+
+ if (state->stage == MESA_SHADER_TESS_CTRL &&
+ !var->data.patch && var->type->is_array()) {
+ type = var->type->fields.array;
+ }
+
+ if (type->is_array() && type->fields.array->is_record()) {
_mesa_glsl_error(&loc, state,
- "vertex shader output "
- "cannot have an array of structs");
+ "%s shader output cannot have "
+ "an array of structs",
+ _mesa_shader_stage_to_string(state->stage));
}
- if (var->type->is_record()) {
- for (unsigned i = 0; i < var->type->length; i++) {
- if (var->type->fields.structure[i].type->is_array() ||
- var->type->fields.structure[i].type->is_record())
+ if (type->is_record()) {
+ for (unsigned i = 0; i < type->length; i++) {
+ if (type->fields.structure[i].type->is_array() ||
+ type->fields.structure[i].type->is_record())
_mesa_glsl_error(&loc, state,
- "vertex shader output cannot have a "
+ "%s shader output cannot have a "
"struct that contains an "
- "array or struct");
+ "array or struct",
+ _mesa_shader_stage_to_string(state->stage));
}
}
}
*
* "[Opaque types] can only be declared as function
* parameters or uniform-qualified variables."
+ *
+ * From section 4.1.7 of the ARB_bindless_texture spec:
+ *
+ * "Samplers may be declared as shader inputs and outputs, as uniform
+ * variables, as temporary variables, and as function parameters."
+ *
+ * From section 4.1.X of the ARB_bindless_texture spec:
+ *
+ * "Images may be declared as shader inputs and outputs, as uniform
+ * variables, as temporary variables, and as function parameters."
*/
- if (var_type->contains_opaque() &&
- !this->type->qualifier.flags.q.uniform) {
+ if (!this->type->qualifier.flags.q.uniform &&
+ (var_type->contains_atomic() ||
+ (!state->has_bindless() && var_type->contains_opaque()))) {
_mesa_glsl_error(&loc, state,
- "opaque variables must be declared uniform");
+ "%s variables must be declared uniform",
+ state->has_bindless() ? "atomic" : "opaque");
}
/* Process the initializer and add its instructions to a temporary
/* Examine var name here since var may get deleted in the next call */
bool var_is_gl_id = is_gl_identifier(var->name);
- ir_variable *earlier =
+ bool is_redeclaration;
+ ir_variable *declared_var =
get_variable_being_redeclared(var, decl->get_location(), state,
- false /* allow_all_redeclarations */);
- if (earlier != NULL) {
+ false /* allow_all_redeclarations */,
+ &is_redeclaration);
+ if (is_redeclaration) {
if (var_is_gl_id &&
- earlier->data.how_declared == ir_var_declared_in_block) {
+ declared_var->data.how_declared == ir_var_declared_in_block) {
_mesa_glsl_error(&loc, state,
"`%s' has already been redeclared using "
- "gl_PerVertex", earlier->name);
+ "gl_PerVertex", declared_var->name);
}
- earlier->data.how_declared = ir_var_declared_normally;
+ declared_var->data.how_declared = ir_var_declared_normally;
}
if (decl->initializer != NULL) {
- result = process_initializer((earlier == NULL) ? var : earlier,
+ result = process_initializer(declared_var,
decl, this->type,
&initializer_instructions, state);
} else {
}
if (state->es_shader) {
- const glsl_type *const t = (earlier == NULL)
- ? var->type : earlier->type;
+ const glsl_type *const t = declared_var->type;
- if (t->is_unsized_array())
+ /* Skip the unsized array check for TCS/TES/GS inputs & TCS outputs.
+ *
+ * The GL_OES_tessellation_shader spec says about inputs:
+ *
+ * "Declaring an array size is optional. If no size is specified,
+ * it will be taken from the implementation-dependent maximum
+ * patch size (gl_MaxPatchVertices)."
+ *
+ * and about TCS outputs:
+ *
+ * "If no size is specified, it will be taken from output patch
+ * size declared in the shader."
+ *
+ * The GL_OES_geometry_shader spec says:
+ *
+ * "All geometry shader input unsized array declarations will be
+ * sized by an earlier input primitive layout qualifier, when
+ * present, as per the following table."
+ */
+ const bool implicitly_sized =
+ (declared_var->data.mode == ir_var_shader_in &&
+ state->stage >= MESA_SHADER_TESS_CTRL &&
+ state->stage <= MESA_SHADER_GEOMETRY) ||
+ (declared_var->data.mode == ir_var_shader_out &&
+ state->stage == MESA_SHADER_TESS_CTRL);
+
+ if (t->is_unsized_array() && !implicitly_sized)
/* Section 10.17 of the GLSL ES 1.00 specification states that
* unsized array declarations have been removed from the language.
* Arrays that are sized using an initializer are still explicitly
* semantic checks that must be applied. In addition, variable that was
* created for the declaration should be added to the IR stream.
*/
- if (earlier == NULL) {
+ if (!is_redeclaration) {
validate_identifier(decl->identifier, loc, state);
/* Add the variable to the symbol table. Note that the initializer's
* after the initializer if present or immediately after the name
* being declared if not."
*/
- if (!state->symbols->add_variable(var)) {
+ if (!state->symbols->add_variable(declared_var)) {
YYLTYPE loc = this->get_location();
_mesa_glsl_error(&loc, state, "name `%s' already taken in the "
"current scope", decl->identifier);
* global var is decled, then the function is defined with usage of
* the global var. See glslparsertest's CorrectModule.frag.
*/
- instructions->push_head(var);
+ instructions->push_head(declared_var);
}
instructions->append_list(&initializer_instructions);
* "Opaque variables cannot be treated as l-values; hence cannot
* be used as out or inout function parameters, nor can they be
* assigned into."
+ *
+ * From section 4.1.7 of the ARB_bindless_texture spec:
+ *
+ * "Samplers can be used as l-values, so can be assigned into and used
+ * as "out" and "inout" function parameters."
+ *
+ * From section 4.1.X of the ARB_bindless_texture spec:
+ *
+ * "Images can be used as l-values, so can be assigned into and used as
+ * "out" and "inout" function parameters."
*/
if ((var->data.mode == ir_var_function_inout || var->data.mode == ir_var_function_out)
- && type->contains_opaque()) {
+ && (type->contains_atomic() ||
+ (!state->has_bindless() && type->contains_opaque()))) {
_mesa_glsl_error(&loc, state, "out and inout parameters cannot "
- "contain opaque variables");
+ "contain %s variables",
+ state->has_bindless() ? "atomic" : "opaque");
type = glsl_type::error_type;
}
state->is_version(120, 100)) {
YYLTYPE loc = this->get_location();
_mesa_glsl_error(&loc, state,
- "declaration of function `%s' not allowed within "
- "function body", name);
+ "declaration of function `%s' not allowed within "
+ "function body", name);
}
validate_identifier(name, this->get_location(), state);
* "Subroutine declarations cannot be prototyped. It is an error to prepend
* subroutine(...) to a function declaration."
*/
- if (this->return_type->qualifier.flags.q.subroutine_def && !is_definition) {
+ if (this->return_type->qualifier.subroutine_list && !is_definition) {
YYLTYPE loc = this->get_location();
_mesa_glsl_error(&loc, state,
"function declaration `%s' cannot have subroutine prepended",
*
* "[Opaque types] can only be declared as function parameters
* or uniform-qualified variables."
+ *
+ * The ARB_bindless_texture spec doesn't clearly state this, but as it says
+ * "Replace Section 4.1.7 (Samplers), p. 25" and, "Replace Section 4.1.X,
+ * (Images)", this should be allowed.
*/
- if (return_type->contains_opaque()) {
+ if (return_type->contains_atomic() ||
+ (!state->has_bindless() && return_type->contains_opaque())) {
YYLTYPE loc = this->get_location();
_mesa_glsl_error(&loc, state,
- "function `%s' return type can't contain an opaque type",
- name);
+ "function `%s' return type can't contain an %s type",
+ name, state->has_bindless() ? "atomic" : "opaque");
}
/**/
f = state->symbols->get_function(name);
if (f == NULL) {
f = new(ctx) ir_function(name);
- if (!this->return_type->qualifier.flags.q.subroutine) {
+ if (!this->return_type->qualifier.is_subroutine_decl()) {
if (!state->symbols->add_function(f)) {
/* This function name shadows a non-function use of the same name. */
YYLTYPE loc = this->get_location();
if (state->es_shader && state->language_version >= 300) {
/* Local shader has no exact candidates; check the built-ins. */
_mesa_glsl_initialize_builtin_functions();
- if (_mesa_glsl_find_builtin_function_by_name(name)) {
+ if (_mesa_glsl_has_builtin_function(name)) {
YYLTYPE loc = this->get_location();
_mesa_glsl_error(& loc, state,
"A shader cannot redefine or overload built-in "
sig->replace_parameters(&hir_parameters);
signature = sig;
- if (this->return_type->qualifier.flags.q.subroutine_def) {
+ if (this->return_type->qualifier.subroutine_list) {
int idx;
if (this->return_type->qualifier.flags.q.explicit_index) {
}
- if (this->return_type->qualifier.flags.q.subroutine) {
+ if (this->return_type->qualifier.is_subroutine_decl()) {
if (!state->symbols->add_type(this->identifier, glsl_type::get_subroutine_instance(this->identifier))) {
_mesa_glsl_error(& loc, state, "type '%s' previously defined", this->identifier);
return NULL;
}
+/* Used for detection of duplicate case values, compare
+ * given contents directly.
+ */
+static bool
+compare_case_value(const void *a, const void *b)
+{
+ return *(unsigned *) a == *(unsigned *) b;
+}
+
+
+/* Used for detection of duplicate case values, just
+ * returns key contents as is.
+ */
+static unsigned
+key_contents(const void *key)
+{
+ return *(unsigned *) key;
+}
+
+
ir_rvalue *
ast_switch_statement::hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state)
state->switch_state.is_switch_innermost = true;
state->switch_state.switch_nesting_ast = this;
- state->switch_state.labels_ht = hash_table_ctor(0, hash_table_pointer_hash,
- hash_table_pointer_compare);
+ state->switch_state.labels_ht =
+ _mesa_hash_table_create(NULL, key_contents,
+ compare_case_value);
state->switch_state.previous_default = NULL;
/* Initalize is_fallthru state to false.
instructions->push_tail(irif);
}
- hash_table_dtor(state->switch_state.labels_ht);
+ _mesa_hash_table_destroy(state->switch_state.labels_ht, NULL);
state->switch_state = saved;
*/
test_expression->set_is_lhs(true);
/* Cache value of test expression. */
- ir_rvalue *const test_val =
- test_expression->hir(instructions,
- state);
+ ir_rvalue *const test_val = test_expression->hir(instructions, state);
state->switch_state.test_var = new(ctx) ir_variable(test_val->type,
"switch_test_tmp",
/* Stuff a dummy value in to allow processing to continue. */
label_const = new(ctx) ir_constant(0);
} else {
- ast_expression *previous_label = (ast_expression *)
- hash_table_find(state->switch_state.labels_ht,
- (void *)(uintptr_t)label_const->value.u[0]);
+ hash_entry *entry =
+ _mesa_hash_table_search(state->switch_state.labels_ht,
+ (void *)(uintptr_t)&label_const->value.u[0]);
- if (previous_label) {
+ if (entry) {
+ ast_expression *previous_label = (ast_expression *) entry->data;
YYLTYPE loc = this->test_value->get_location();
_mesa_glsl_error(& loc, state, "duplicate case value");
loc = previous_label->get_location();
_mesa_glsl_error(& loc, state, "this is the previous case label");
} else {
- hash_table_insert(state->switch_state.labels_ht,
- this->test_value,
- (void *)(uintptr_t)label_const->value.u[0]);
+ _mesa_hash_table_insert(state->switch_state.labels_ht,
+ (void *)(uintptr_t)&label_const->value.u[0],
+ this->test_value);
}
}
* the types to HIR. This ensures that structure definitions embedded in
* other structure definitions or in interface blocks are processed.
*/
- glsl_struct_field *const fields = ralloc_array(state, glsl_struct_field,
- decl_count);
+ glsl_struct_field *const fields = rzalloc_array(state, glsl_struct_field,
+ decl_count);
bool first_member = true;
bool first_member_has_explicit_location = false;
"to struct or interface block members");
}
+ validate_memory_qualifier_for_type(state, &loc, qual, decl_type);
+ validate_image_format_qualifier_for_type(state, &loc, qual, decl_type);
+
/* From Section 4.4.2.3 (Geometry Outputs) of the GLSL 4.50 spec:
*
* "A block member may be declared with a stream identifier, but
unsigned qual_location;
if (process_qualifier_constant(state, &loc, "location",
qual->location, &qual_location)) {
- fields[i].location = VARYING_SLOT_VAR0 + qual_location;
+ fields[i].location = qual_location +
+ (fields[i].patch ? VARYING_SLOT_PATCH0 : VARYING_SLOT_VAR0);
expl_location = fields[i].location +
fields[i].type->count_attribute_slots(false);
}
* if set, overwrites the layout qualifier.
*/
if (qual->flags.q.read_only) {
- fields[i].image_read_only = true;
- fields[i].image_write_only = false;
+ fields[i].memory_read_only = true;
+ fields[i].memory_write_only = false;
} else if (qual->flags.q.write_only) {
- fields[i].image_read_only = false;
- fields[i].image_write_only = true;
+ fields[i].memory_read_only = false;
+ fields[i].memory_write_only = true;
} else {
- fields[i].image_read_only = layout->flags.q.read_only;
- fields[i].image_write_only = layout->flags.q.write_only;
+ fields[i].memory_read_only = layout->flags.q.read_only;
+ fields[i].memory_write_only = layout->flags.q.write_only;
}
/* For other qualifiers, we set the flag if either the layout
* qualifier or the field qualifier are set
*/
- fields[i].image_coherent = qual->flags.q.coherent ||
+ fields[i].memory_coherent = qual->flags.q.coherent ||
layout->flags.q.coherent;
- fields[i].image_volatile = qual->flags.q._volatile ||
+ fields[i].memory_volatile = qual->flags.q._volatile ||
layout->flags.q._volatile;
- fields[i].image_restrict = qual->flags.q.restrict_flag ||
+ fields[i].memory_restrict = qual->flags.q.restrict_flag ||
layout->flags.q.restrict_flag;
}
static void
apply_memory_qualifiers(ir_variable *var, glsl_struct_field field)
{
- var->data.image_read_only = field.image_read_only;
- var->data.image_write_only = field.image_write_only;
- var->data.image_coherent = field.image_coherent;
- var->data.image_volatile = field.image_volatile;
- var->data.image_restrict = field.image_restrict;
+ var->data.memory_read_only = field.memory_read_only;
+ var->data.memory_write_only = field.memory_write_only;
+ var->data.memory_coherent = field.memory_coherent;
+ var->data.memory_volatile = field.memory_volatile;
+ var->data.memory_restrict = field.memory_restrict;
}
ir_rvalue *
this->block_name);
}
- if (!this->layout.flags.q.buffer &&
- this->layout.flags.q.std430) {
- _mesa_glsl_error(&loc, state,
- "std430 storage block layout qualifier is supported "
- "only for shader storage blocks");
+ /* Validate qualifiers:
+ *
+ * - Layout Qualifiers as per the table in Section 4.4
+ * ("Layout Qualifiers") of the GLSL 4.50 spec.
+ *
+ * - Memory Qualifiers as per Section 4.10 ("Memory Qualifiers") of the
+ * GLSL 4.50 spec:
+ *
+ * "Additionally, memory qualifiers may also be used in the declaration
+ * of shader storage blocks"
+ *
+ * Note the table in Section 4.4 says std430 is allowed on both uniform and
+ * buffer blocks however Section 4.4.5 (Uniform and Shader Storage Block
+ * Layout Qualifiers) of the GLSL 4.50 spec says:
+ *
+ * "The std430 qualifier is supported only for shader storage blocks;
+ * using std430 on a uniform block will result in a compile-time error."
+ */
+ ast_type_qualifier allowed_blk_qualifiers;
+ allowed_blk_qualifiers.flags.i = 0;
+ if (this->layout.flags.q.buffer || this->layout.flags.q.uniform) {
+ allowed_blk_qualifiers.flags.q.shared = 1;
+ allowed_blk_qualifiers.flags.q.packed = 1;
+ allowed_blk_qualifiers.flags.q.std140 = 1;
+ allowed_blk_qualifiers.flags.q.row_major = 1;
+ allowed_blk_qualifiers.flags.q.column_major = 1;
+ allowed_blk_qualifiers.flags.q.explicit_align = 1;
+ allowed_blk_qualifiers.flags.q.explicit_binding = 1;
+ if (this->layout.flags.q.buffer) {
+ allowed_blk_qualifiers.flags.q.buffer = 1;
+ allowed_blk_qualifiers.flags.q.std430 = 1;
+ allowed_blk_qualifiers.flags.q.coherent = 1;
+ allowed_blk_qualifiers.flags.q._volatile = 1;
+ allowed_blk_qualifiers.flags.q.restrict_flag = 1;
+ allowed_blk_qualifiers.flags.q.read_only = 1;
+ allowed_blk_qualifiers.flags.q.write_only = 1;
+ } else {
+ allowed_blk_qualifiers.flags.q.uniform = 1;
+ }
+ } else {
+ /* Interface block */
+ assert(this->layout.flags.q.in || this->layout.flags.q.out);
+
+ allowed_blk_qualifiers.flags.q.explicit_location = 1;
+ if (this->layout.flags.q.out) {
+ allowed_blk_qualifiers.flags.q.out = 1;
+ if (state->stage == MESA_SHADER_GEOMETRY ||
+ state->stage == MESA_SHADER_TESS_CTRL ||
+ state->stage == MESA_SHADER_TESS_EVAL ||
+ state->stage == MESA_SHADER_VERTEX ) {
+ allowed_blk_qualifiers.flags.q.explicit_xfb_offset = 1;
+ allowed_blk_qualifiers.flags.q.explicit_xfb_buffer = 1;
+ allowed_blk_qualifiers.flags.q.xfb_buffer = 1;
+ allowed_blk_qualifiers.flags.q.explicit_xfb_stride = 1;
+ allowed_blk_qualifiers.flags.q.xfb_stride = 1;
+ if (state->stage == MESA_SHADER_GEOMETRY) {
+ allowed_blk_qualifiers.flags.q.stream = 1;
+ allowed_blk_qualifiers.flags.q.explicit_stream = 1;
+ }
+ if (state->stage == MESA_SHADER_TESS_CTRL) {
+ allowed_blk_qualifiers.flags.q.patch = 1;
+ }
+ }
+ } else {
+ allowed_blk_qualifiers.flags.q.in = 1;
+ if (state->stage == MESA_SHADER_TESS_EVAL) {
+ allowed_blk_qualifiers.flags.q.patch = 1;
+ }
+ }
}
+ this->layout.validate_flags(&loc, state, allowed_blk_qualifiers,
+ "invalid qualifier for block",
+ this->block_name);
+
/* The ast_interface_block has a list of ast_declarator_lists. We
* need to turn those into ir_variables with an association
* with this uniform block.
"Interface block sets both readonly and writeonly");
}
- if (this->layout.flags.q.explicit_component) {
- _mesa_glsl_error(&loc, state, "component layout qualifier cannot be "
- "applied to a matrix, a structure, a block, or an "
- "array containing any of these.");
- }
-
unsigned qual_stream;
if (!process_qualifier_constant(state, &loc, "stream", this->layout.stream,
&qual_stream) ||
layout.location, &expl_location)) {
return NULL;
} else {
- expl_location = VARYING_SLOT_VAR0 + expl_location;
+ expl_location += this->layout.flags.q.patch ? VARYING_SLOT_PATCH0
+ : VARYING_SLOT_VAR0;
}
}
return NULL;
} else {
if (expl_align == 0 || expl_align & (expl_align - 1)) {
- _mesa_glsl_error(&loc, state, "align layout qualifier in not a "
+ _mesa_glsl_error(&loc, state, "align layout qualifier is not a "
"power of 2.");
return NULL;
}
glsl_type::get_interface_instance(fields,
num_variables,
packing,
+ matrix_layout ==
+ GLSL_MATRIX_LAYOUT_ROW_MAJOR,
this->block_name);
unsigned component_size = block_type->contains_double() ? 8 : 4;
_mesa_glsl_error(&loc, state, "geometry shader inputs must be arrays");
} else if ((state->stage == MESA_SHADER_TESS_CTRL ||
state->stage == MESA_SHADER_TESS_EVAL) &&
+ !this->layout.flags.q.patch &&
this->array_specifier == NULL &&
var_mode == ir_var_shader_in) {
_mesa_glsl_error(&loc, state, "per-vertex tessellation shader inputs must be arrays");
} else if (state->stage == MESA_SHADER_TESS_CTRL &&
+ !this->layout.flags.q.patch &&
this->array_specifier == NULL &&
var_mode == ir_var_shader_out) {
_mesa_glsl_error(&loc, state, "tessellation control shader outputs must be arrays");
if (var_mode == ir_var_shader_in || var_mode == ir_var_uniform)
var->data.read_only = true;
+ var->data.patch = this->layout.flags.q.patch;
+
if (state->stage == MESA_SHADER_GEOMETRY && var_mode == ir_var_shader_in)
handle_geometry_shader_input_decl(state, loc, var);
else if ((state->stage == MESA_SHADER_TESS_CTRL ||
bool var_is_gl_id = is_gl_identifier(var->name);
if (redeclaring_per_vertex) {
- ir_variable *earlier =
+ bool is_redeclaration;
+ ir_variable *declared_var =
get_variable_being_redeclared(var, loc, state,
- true /* allow_all_redeclarations */);
- if (!var_is_gl_id || earlier == NULL) {
+ true /* allow_all_redeclarations */,
+ &is_redeclaration);
+ if (!var_is_gl_id || !is_redeclaration) {
_mesa_glsl_error(&loc, state,
"redeclaration of gl_PerVertex can only "
"include built-in variables");
- } else if (earlier->data.how_declared == ir_var_declared_normally) {
+ } else if (declared_var->data.how_declared == ir_var_declared_normally) {
_mesa_glsl_error(&loc, state,
"`%s' has already been redeclared",
- earlier->name);
+ declared_var->name);
} else {
- earlier->data.how_declared = ir_var_declared_in_block;
- earlier->reinit_interface_type(block_type);
+ declared_var->data.how_declared = ir_var_declared_in_block;
+ declared_var->reinit_interface_type(block_type);
}
continue;
}
}
if (var->type->is_unsized_array()) {
- if (var->is_in_shader_storage_block()) {
- if (is_unsized_array_last_element(var)) {
- var->data.from_ssbo_unsized_array = true;
- }
+ if (var->is_in_shader_storage_block() &&
+ is_unsized_array_last_element(var)) {
+ var->data.from_ssbo_unsized_array = true;
} else {
/* From GLSL ES 3.10 spec, section 4.1.9 "Arrays":
*
* block and the size is not specified at compile-time, it is
* sized at run-time. In all other cases, arrays are sized only
* at compile-time."
+ *
+ * In desktop GLSL it is allowed to have unsized-arrays that are
+ * not last, as long as we can determine that they are implicitly
+ * sized.
*/
if (state->es_shader) {
_mesa_glsl_error(&loc, state, "unsized array `%s' "
ir_rvalue *
ast_tcs_output_layout::hir(exec_list *instructions,
- struct _mesa_glsl_parse_state *state)
+ struct _mesa_glsl_parse_state *state)
{
YYLTYPE loc = this->get_location();
*/
if (state->tcs_output_size != 0 && state->tcs_output_size != num_vertices) {
_mesa_glsl_error(&loc, state,
- "this tessellation control shader output layout "
- "specifies %u vertices, but a previous output "
- "is declared with size %u",
- num_vertices, state->tcs_output_size);
+ "this tessellation control shader output layout "
+ "specifies %u vertices, but a previous output "
+ "is declared with size %u",
+ num_vertices, state->tcs_output_size);
return NULL;
}
foreach_in_list (ir_instruction, node, instructions) {
ir_variable *var = node->as_variable();
if (var == NULL || var->data.mode != ir_var_shader_out)
- continue;
+ continue;
/* Note: Not all tessellation control shader output are arrays. */
if (!var->type->is_unsized_array() || var->data.patch)
continue;
if (var->data.max_array_access >= (int)num_vertices) {
- _mesa_glsl_error(&loc, state,
- "this tessellation control shader output layout "
- "specifies %u vertices, but an access to element "
- "%u of output `%s' already exists", num_vertices,
- var->data.max_array_access, var->name);
+ _mesa_glsl_error(&loc, state,
+ "this tessellation control shader output layout "
+ "specifies %u vertices, but an access to element "
+ "%u of output `%s' already exists", num_vertices,
+ var->data.max_array_access, var->name);
} else {
- var->type = glsl_type::get_array_instance(var->type->fields.array,
- num_vertices);
+ var->type = glsl_type::get_array_instance(var->type->fields.array,
+ num_vertices);
}
}
{
YYLTYPE loc = this->get_location();
- /* If any geometry input layout declaration preceded this one, make sure it
- * was consistent with this one.
- */
- if (state->gs_input_prim_type_specified &&
- state->in_qualifier->prim_type != this->prim_type) {
- _mesa_glsl_error(&loc, state,
- "geometry shader input layout does not match"
- " previous declaration");
- return NULL;
- }
+ /* Should have been prevented by the parser. */
+ assert(!state->gs_input_prim_type_specified
+ || state->in_qualifier->prim_type == this->prim_type);
/* If any shader inputs occurred before this declaration and specified an
* array size, make sure the size they specified is consistent with the
}
}
+ /* The ARB_compute_variable_group_size spec says:
+ *
+ * If a compute shader including a *local_size_variable* qualifier also
+ * declares a fixed local group size using the *local_size_x*,
+ * *local_size_y*, or *local_size_z* qualifiers, a compile-time error
+ * results
+ */
+ if (state->cs_input_local_size_variable_specified) {
+ _mesa_glsl_error(&loc, state,
+ "compute shader can't include both a variable and a "
+ "fixed local group size");
+ return NULL;
+ }
+
state->cs_input_local_size_specified = true;
for (int i = 0; i < 3; i++)
state->cs_input_local_size[i] = qual_local_size[i];
gl_FragColor_assigned = true;
else if (strcmp(var->name, "gl_FragData") == 0)
gl_FragData_assigned = true;
- else if (strcmp(var->name, "gl_SecondaryFragColorEXT") == 0)
+ else if (strcmp(var->name, "gl_SecondaryFragColorEXT") == 0)
gl_FragSecondaryColor_assigned = true;
- else if (strcmp(var->name, "gl_SecondaryFragDataEXT") == 0)
+ else if (strcmp(var->name, "gl_SecondaryFragDataEXT") == 0)
gl_FragSecondaryData_assigned = true;
else if (!is_gl_identifier(var->name)) {
if (state->stage == MESA_SHADER_FRAGMENT &&