Yes, this is a bit hacky but we don't really have the choice.
Plain GLSL doesn't accept bindless samplers/images as l-values
while it's allowed when ARB_bindless_texture is enabled.
The default NULL parameter is because we can't access the
_mesa_glsl_parse_state object in few places in the compiler.
One is_lvalue(NULL) call is for IR validation but other checks
happen elsewhere, should be safe.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
mode, formal->name,
actual->variable_referenced()->name);
return false;
- } else if (!actual->is_lvalue()) {
+ } else if (!actual->is_lvalue(state)) {
_mesa_glsl_error(&loc, state,
"function parameter '%s %s' is not an lvalue",
mode, formal->name);
* The restriction on arrays is lifted in GLSL 1.20 and GLSL ES 3.00.
*/
error_emitted = true;
- } else if (!lhs->is_lvalue()) {
+ } else if (!lhs->is_lvalue(state)) {
_mesa_glsl_error(& lhs_loc, state, "non-lvalue in assignment");
error_emitted = true;
}
#include "main/core.h" /* for MAX2 */
#include "ir.h"
#include "compiler/glsl_types.h"
+#include "glsl_parser_extras.h"
+
ir_rvalue::ir_rvalue(enum ir_node_type t)
: ir_instruction(t)
}
bool
-ir_dereference::is_lvalue() const
+ir_dereference::is_lvalue(const struct _mesa_glsl_parse_state *state) const
{
ir_variable *var = this->variable_referenced();
ir_rvalue *as_rvalue_to_saturate();
- virtual bool is_lvalue() const
+ virtual bool is_lvalue(const struct _mesa_glsl_parse_state *state = NULL) const
{
return false;
}
virtual bool equals(const ir_instruction *ir,
enum ir_node_type ignore = ir_type_unset) const;
- bool is_lvalue() const
+ bool is_lvalue(const struct _mesa_glsl_parse_state *state) const
{
- return val->is_lvalue() && !mask.has_duplicates;
+ return val->is_lvalue(state) && !mask.has_duplicates;
}
/**
public:
virtual ir_dereference *clone(void *mem_ctx, struct hash_table *) const = 0;
- bool is_lvalue() const;
+ bool is_lvalue(const struct _mesa_glsl_parse_state *state) const;
/**
* Get the variable that is ultimately referenced by an r-value