if (lhs_var)
lhs_var->data.assigned = true;
+ bool omit_assignment = false;
if (!error_emitted) {
if (non_lvalue_description != NULL) {
_mesa_glsl_error(&lhs_loc, state,
* no such distinction, that is why this check here is limited to
* buffer variables alone.
*/
- _mesa_glsl_error(&lhs_loc, state,
- "assignment to read-only variable '%s'",
- lhs_var->name);
- error_emitted = true;
+
+ if (state->ignore_write_to_readonly_var)
+ omit_assignment = true;
+ else {
+ _mesa_glsl_error(&lhs_loc, state,
+ "assignment to read-only variable '%s'",
+ lhs_var->name);
+ error_emitted = true;
+ }
} else if (lhs->type->is_array() &&
!state->check_version(state->allow_glsl_120_subset_in_110 ? 110 : 120,
300, &lhs_loc,
error_emitted = true;
}
+ if (omit_assignment) {
+ *out_rvalue = needs_rvalue ? ir_rvalue::error_value(ctx) : NULL;
+ return error_emitted;
+ }
+
/* Most callers of do_assignment (assign, add_assign, pre_inc/dec,
* but not post_inc) need the converted assigned value as an rvalue
* to handle things like:
ctx->Const.AllowGLSL120SubsetIn110;
this->allow_builtin_variable_redeclaration =
ctx->Const.AllowGLSLBuiltinVariableRedeclaration;
+ this->ignore_write_to_readonly_var =
+ ctx->Const.GLSLIgnoreWriteToReadonlyVar;
this->cs_input_local_size_variable_specified = false;
bool allow_extension_directive_midshader;
bool allow_glsl_120_subset_in_110;
bool allow_builtin_variable_redeclaration;
+ bool ignore_write_to_readonly_var;
/**
* Known subroutine type declarations.
DRI_CONF_ALLOW_HIGHER_COMPAT_VERSION(false)
DRI_CONF_FORCE_GLSL_ABS_SQRT(false)
DRI_CONF_GLSL_CORRECT_DERIVATIVES_AFTER_DISCARD(false)
+ DRI_CONF_GLSL_IGNORE_WRITE_TO_READONLY_VAR(false)
DRI_CONF_ALLOW_DRAW_OUT_OF_ORDER(false)
DRI_CONF_ALLOW_INCORRECT_PRIMITIVE_ID(false)
DRI_CONF_FORCE_COMPAT_PROFILE(false)
driQueryOptionb(optionCache, "allow_glsl_builtin_variable_redeclaration");
options->allow_higher_compat_version =
driQueryOptionb(optionCache, "allow_higher_compat_version");
+ options->glsl_ignore_write_to_readonly_var =
+ driQueryOptionb(optionCache, "glsl_ignore_write_to_readonly_var");
options->glsl_zero_init = driQueryOptionb(optionCache, "glsl_zero_init");
options->force_integer_tex_nearest =
driQueryOptionb(optionCache, "force_integer_tex_nearest");
bool allow_glsl_relaxed_es;
bool allow_glsl_builtin_variable_redeclaration;
bool allow_higher_compat_version;
+ bool glsl_ignore_write_to_readonly_var;
bool glsl_zero_init;
bool vs_position_always_invariant;
bool force_glsl_abs_sqrt;
GLboolean ForceGLSLAbsSqrt;
/**
+ * Forces the GLSL compiler to ignore writes to readonly vars rather than
+ * throwing an error.
+ */
+ GLboolean GLSLIgnoreWriteToReadonlyVar;
+
+ /**
* Types of variable to default initialized to zero. Supported values are:
* - 0: no zero initialization
* - 1: all shader variables and gl_FragColor are initialiazed to 0
consts->AllowGLSLCrossStageInterpolationMismatch = options->allow_glsl_cross_stage_interpolation_mismatch;
+ consts->GLSLIgnoreWriteToReadonlyVar = options->glsl_ignore_write_to_readonly_var;
+
consts->PrimitiveRestartFixedIndex =
screen->get_param(screen, PIPE_CAP_PRIMITIVE_RESTART_FIXED_INDEX);
DRI_CONF_OPT_B(glsl_correct_derivatives_after_discard, def, \
"Implicit and explicit derivatives after a discard behave as if the discard didn't happen")
+#define DRI_CONF_GLSL_IGNORE_WRITE_TO_READONLY_VAR(def) \
+ DRI_CONF_OPT_B(glsl_ignore_write_to_readonly_var, def, \
+ "Forces the GLSL compiler to ignore writes to readonly vars rather than throwing an error")
+
#define DRI_CONF_ALLOW_GLSL_CROSS_STAGE_INTERPOLATION_MISMATCH(def) \
DRI_CONF_OPT_B(allow_glsl_cross_stage_interpolation_mismatch, def, \
"Allow interpolation qualifier mismatch across shader stages")