if (type->base_type == GLSL_TYPE_FLOAT
&& state->es_shader
- && state->target == fragment_shader
+ && state->target == MESA_SHADER_FRAGMENT
&& this->qualifier.precision == ast_precision_none
&& state->symbols->get_variable("#default precision") == NULL) {
YYLTYPE loc = this->get_location();
* this function will produce undefined results.
*/
static bool
-is_varying_var(ir_variable *var, _mesa_glsl_parser_targets target)
+is_varying_var(ir_variable *var, gl_shader_type target)
{
switch (target) {
- case vertex_shader:
+ case MESA_SHADER_VERTEX:
return var->data.mode == ir_var_shader_out;
- case fragment_shader:
+ case MESA_SHADER_FRAGMENT:
return var->data.mode == ir_var_shader_in;
default:
return var->data.mode == ir_var_shader_out || var->data.mode == ir_var_shader_in;
*/
unsigned limit = 0;
switch (state->target) {
- case vertex_shader:
+ case MESA_SHADER_VERTEX:
limit = ctx->Const.VertexProgram.MaxTextureImageUnits;
break;
- case geometry_shader:
+ case MESA_SHADER_GEOMETRY:
limit = ctx->Const.GeometryProgram.MaxTextureImageUnits;
break;
- case fragment_shader:
+ case MESA_SHADER_FRAGMENT:
limit = ctx->Const.FragmentProgram.MaxTextureImageUnits;
break;
}
}
- if ((state->target == vertex_shader && mode == ir_var_shader_in) ||
- (state->target == fragment_shader && mode == ir_var_shader_out)) {
+ if ((state->target == MESA_SHADER_VERTEX && mode == ir_var_shader_in) ||
+ (state->target == MESA_SHADER_FRAGMENT && mode == ir_var_shader_out)) {
_mesa_glsl_error(loc, state,
"interpolation qualifier `%s' cannot be applied to "
"vertex shader inputs or fragment shader outputs",
* locations.
*/
switch (state->target) {
- case vertex_shader:
+ case MESA_SHADER_VERTEX:
if (var->data.mode == ir_var_shader_in) {
if (!state->check_explicit_attrib_location_allowed(loc, var))
return;
fail = true;
break;
- case geometry_shader:
+ case MESA_SHADER_GEOMETRY:
_mesa_glsl_error(loc, state,
"geometry shader variables cannot be given "
"explicit locations");
return;
- case fragment_shader:
+ case MESA_SHADER_FRAGMENT:
if (var->data.mode == ir_var_shader_out) {
if (!state->check_explicit_attrib_location_allowed(loc, var))
return;
* ensures that negative values stay negative.
*/
if (qual->location >= 0) {
- var->data.location = (state->target == vertex_shader)
+ var->data.location = (state->target == MESA_SHADER_VERTEX)
? (qual->location + VERT_ATTRIB_GENERIC0)
: (qual->location + FRAG_RESULT_DATA0);
} else {
if (qual->flags.q.constant || qual->flags.q.attribute
|| qual->flags.q.uniform
- || (qual->flags.q.varying && (state->target == fragment_shader)))
+ || (qual->flags.q.varying && (state->target == MESA_SHADER_FRAGMENT)))
var->data.read_only = 1;
if (qual->flags.q.centroid)
if (qual->flags.q.sample)
var->data.sample = 1;
- if (qual->flags.q.attribute && state->target != vertex_shader) {
+ if (qual->flags.q.attribute && state->target != MESA_SHADER_VERTEX) {
var->type = glsl_type::error_type;
_mesa_glsl_error(loc, state,
"`attribute' variables may not be declared in the "
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->target == fragment_shader)))
+ || (qual->flags.q.varying && (state->target == 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.varying && (state->target == vertex_shader))
+ else if (qual->flags.q.varying && (state->target == MESA_SHADER_VERTEX))
var->data.mode = ir_var_shader_out;
else if (qual->flags.q.uniform)
var->data.mode = ir_var_uniform;
if (state->all_invariant && (state->current_function == NULL)) {
switch (state->target) {
- case vertex_shader:
+ case MESA_SHADER_VERTEX:
if (var->data.mode == ir_var_shader_out)
var->data.invariant = true;
break;
- case geometry_shader:
+ case MESA_SHADER_GEOMETRY:
if ((var->data.mode == ir_var_shader_in)
|| (var->data.mode == ir_var_shader_out))
var->data.invariant = true;
break;
- case fragment_shader:
+ case MESA_SHADER_FRAGMENT:
if (var->data.mode == ir_var_shader_in)
var->data.invariant = true;
break;
_mesa_glsl_error(& initializer_loc, state,
"cannot initialize %s shader input / %s",
_mesa_glsl_shader_target_name(state->target),
- (state->target == vertex_shader)
+ (state->target == MESA_SHADER_VERTEX)
? "attribute" : "varying");
}
_mesa_glsl_error(& loc, state,
"undeclared variable `%s' cannot be marked "
"invariant", decl->identifier);
- } else if ((state->target == vertex_shader)
+ } else if ((state->target == MESA_SHADER_VERTEX)
&& (earlier->data.mode != ir_var_shader_out)) {
_mesa_glsl_error(& loc, state,
"`%s' cannot be marked invariant, vertex shader "
"outputs only", decl->identifier);
- } else if ((state->target == fragment_shader)
+ } else if ((state->target == MESA_SHADER_FRAGMENT)
&& (earlier->data.mode != ir_var_shader_in)) {
_mesa_glsl_error(& loc, state,
"`%s' cannot be marked invariant, fragment shader "
& loc, false);
if (this->type->qualifier.flags.q.invariant) {
- if ((state->target == vertex_shader) &&
+ if ((state->target == MESA_SHADER_VERTEX) &&
var->data.mode != ir_var_shader_out) {
_mesa_glsl_error(& loc, state,
"`%s' cannot be marked invariant, vertex shader "
"outputs only", var->name);
- } else if ((state->target == fragment_shader) &&
+ } else if ((state->target == MESA_SHADER_FRAGMENT) &&
var->data.mode != ir_var_shader_in) {
/* FINISHME: Note that this doesn't work for invariant on
* a function signature inval
} else if (var->data.mode == ir_var_shader_in) {
var->data.read_only = true;
- if (state->target == vertex_shader) {
+ if (state->target == MESA_SHADER_VERTEX) {
bool error_emitted = false;
/* From page 31 (page 37 of the PDF) of the GLSL 1.50 spec:
"cannot have array type")) {
error_emitted = true;
}
- } else if (state->target == geometry_shader) {
+ } else if (state->target == MESA_SHADER_GEOMETRY) {
/* From section 4.3.4 (Inputs) of the GLSL 1.50 spec:
*
* Geometry shader input variables get the per-vertex values
if (state->is_version(130, 300) &&
var->type->contains_integer() &&
var->data.interpolation != INTERP_QUALIFIER_FLAT &&
- ((state->target == fragment_shader && var->data.mode == ir_var_shader_in)
- || (state->target == vertex_shader && var->data.mode == ir_var_shader_out
+ ((state->target == MESA_SHADER_FRAGMENT && var->data.mode == ir_var_shader_in)
+ || (state->target == MESA_SHADER_VERTEX && var->data.mode == ir_var_shader_out
&& state->es_shader))) {
- const char *var_type = (state->target == vertex_shader) ?
+ const char *var_type = (state->target == 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'",
assert(i != NULL);
switch (state->target) {
- case vertex_shader:
+ case MESA_SHADER_VERTEX:
if (this->type->qualifier.flags.q.in) {
_mesa_glsl_error(&loc, state,
"qualifier '%s' cannot be applied to vertex "
"shader inputs", i);
}
break;
- case fragment_shader:
+ case MESA_SHADER_FRAGMENT:
if (this->type->qualifier.flags.q.out) {
_mesa_glsl_error(&loc, state,
"qualifier '%s' cannot be applied to fragment "
if (state->is_version(130, 300)
&& this->type->qualifier.flags.q.centroid
&& this->type->qualifier.flags.q.in
- && state->target == vertex_shader) {
+ && state->target == MESA_SHADER_VERTEX) {
_mesa_glsl_error(&loc, state,
"'centroid in' cannot be used in a vertex shader");
}
- if (state->target == vertex_shader
+ if (state->target == MESA_SHADER_VERTEX
&& this->type->qualifier.flags.q.sample
&& this->type->qualifier.flags.q.in) {
* "It is an error to use auxiliary storage qualifiers or interpolation
* qualifiers on an output in a fragment shader."
*/
- if (state->target == fragment_shader &&
+ if (state->target == MESA_SHADER_FRAGMENT &&
this->type->qualifier.flags.q.out &&
this->type->qualifier.has_auxiliary_storage()) {
_mesa_glsl_error(&loc, state,
}
case ast_discard:
- if (state->target != fragment_shader) {
+ if (state->target != MESA_SHADER_FRAGMENT) {
YYLTYPE loc = this->get_location();
_mesa_glsl_error(& loc, state,
if (type->base_type == GLSL_TYPE_FLOAT
&& state->es_shader
- && state->target == fragment_shader) {
+ && state->target == MESA_SHADER_FRAGMENT) {
/* Section 4.5.3 (Default Precision Qualifiers) of the GLSL ES 1.00
* spec says:
*
* variable (or input block, see interface blocks below) needs to be
* declared as an array.
*/
- if (state->target == geometry_shader && !this->is_array &&
+ if (state->target == MESA_SHADER_GEOMETRY && !this->is_array &&
var_mode == ir_var_shader_in) {
_mesa_glsl_error(&loc, state, "geometry shader inputs must be arrays");
}
* geometry shader input.
*/
if (this->array_size == NULL &&
- (state->target != geometry_shader || !this->layout.flags.q.in)) {
+ (state->target != MESA_SHADER_GEOMETRY || !this->layout.flags.q.in)) {
_mesa_glsl_error(&loc, state,
"only geometry shader inputs may be unsized "
"instance block arrays");
var_mode);
}
- if (state->target == geometry_shader && var_mode == ir_var_shader_in)
+ if (state->target == MESA_SHADER_GEOMETRY && var_mode == ir_var_shader_in)
handle_geometry_shader_input_decl(state, loc, var);
if (ir_variable *earlier =
else if (strcmp(var->name, "gl_FragData") == 0)
gl_FragData_assigned = true;
else if (strncmp(var->name, "gl_", 3) != 0) {
- if (state->target == fragment_shader &&
+ if (state->target == MESA_SHADER_FRAGMENT &&
var->data.mode == ir_var_shader_out) {
user_defined_fs_output_assigned = true;
user_defined_fs_output = var;
static bool
compatibility_vs_only(const _mesa_glsl_parse_state *state)
{
- return state->target == vertex_shader &&
+ return state->target == MESA_SHADER_VERTEX &&
state->language_version <= 130 &&
!state->es_shader;
}
static bool
fs_only(const _mesa_glsl_parse_state *state)
{
- return state->target == fragment_shader;
+ return state->target == MESA_SHADER_FRAGMENT;
}
static bool
gs_only(const _mesa_glsl_parse_state *state)
{
- return state->target == geometry_shader;
+ return state->target == MESA_SHADER_GEOMETRY;
}
static bool
static bool
v110_fs_only(const _mesa_glsl_parse_state *state)
{
- return !state->es_shader && state->target == fragment_shader;
+ return !state->es_shader && state->target == MESA_SHADER_FRAGMENT;
}
static bool
v130_fs_only(const _mesa_glsl_parse_state *state)
{
return state->is_version(130, 300) &&
- state->target == fragment_shader;
+ state->target == MESA_SHADER_FRAGMENT;
}
static bool
* Since ARB_shader_texture_lod can only be enabled on desktop GLSL, we
* don't need to explicitly check state->es_shader.
*/
- return state->target == vertex_shader ||
+ return state->target == MESA_SHADER_VERTEX ||
state->is_version(130, 300) ||
state->ARB_shader_texture_lod_enable;
}
static bool
fs_texture_array(const _mesa_glsl_parse_state *state)
{
- return state->target == fragment_shader &&
+ return state->target == MESA_SHADER_FRAGMENT &&
state->EXT_texture_array_enable;
}
static bool
fs_texture_cube_map_array(const _mesa_glsl_parse_state *state)
{
- return state->target == fragment_shader &&
+ return state->target == MESA_SHADER_FRAGMENT &&
(state->is_version(400, 0) ||
state->ARB_texture_cube_map_array_enable);
}
static bool
texture_query_lod(const _mesa_glsl_parse_state *state)
{
- return state->target == fragment_shader &&
+ return state->target == MESA_SHADER_FRAGMENT &&
state->ARB_texture_query_lod_enable;
}
static bool
fs_oes_derivatives(const _mesa_glsl_parse_state *state)
{
- return state->target == fragment_shader &&
+ return state->target == MESA_SHADER_FRAGMENT &&
(state->is_version(110, 300) ||
state->OES_standard_derivatives_enable);
}
static bool
fs_tex3d(const _mesa_glsl_parse_state *state)
{
- return state->target == fragment_shader &&
+ return state->target == MESA_SHADER_FRAGMENT &&
(!state->es_shader || state->OES_texture_3D_enable);
}
const char *name_as_gs_input)
{
switch (state->target) {
- case geometry_shader:
+ case MESA_SHADER_GEOMETRY:
this->per_vertex_in.add_field(slot, type, name);
/* FALLTHROUGH */
- case vertex_shader:
+ case MESA_SHADER_VERTEX:
this->per_vertex_out.add_field(slot, type, name);
break;
- case fragment_shader:
+ case MESA_SHADER_FRAGMENT:
add_input(slot, type, name);
break;
}
add_varying(loc, type, name, name "In")
/* gl_Position and gl_PointSize are not visible from fragment shaders. */
- if (state->target != fragment_shader) {
+ if (state->target != MESA_SHADER_FRAGMENT) {
ADD_VARYING(VARYING_SLOT_POS, vec4_t, "gl_Position");
ADD_VARYING(VARYING_SLOT_PSIZ, float_t, "gl_PointSize");
}
if (compatibility) {
ADD_VARYING(VARYING_SLOT_TEX0, array(vec4_t, 0), "gl_TexCoord");
ADD_VARYING(VARYING_SLOT_FOGC, float_t, "gl_FogFragCoord");
- if (state->target == fragment_shader) {
+ if (state->target == MESA_SHADER_FRAGMENT) {
ADD_VARYING(VARYING_SLOT_COL0, vec4_t, "gl_Color");
ADD_VARYING(VARYING_SLOT_COL1, vec4_t, "gl_SecondaryColor");
} else {
}
}
- if (state->target == geometry_shader) {
+ if (state->target == MESA_SHADER_GEOMETRY) {
const glsl_type *per_vertex_in_type =
this->per_vertex_in.construct_interface_instance();
add_variable("gl_in", array(per_vertex_in_type, 0),
ir_var_shader_in, -1);
}
- if (state->target == vertex_shader || state->target == geometry_shader) {
+ if (state->target == MESA_SHADER_VERTEX || state->target == MESA_SHADER_GEOMETRY) {
const glsl_type *per_vertex_out_type =
this->per_vertex_out.construct_interface_instance();
const glsl_struct_field *fields = per_vertex_out_type->fields.structure;
gen.generate_varyings();
switch (state->target) {
- case vertex_shader:
+ case MESA_SHADER_VERTEX:
gen.generate_vs_special_vars();
break;
- case geometry_shader:
+ case MESA_SHADER_GEOMETRY:
gen.generate_gs_special_vars();
break;
- case fragment_shader:
+ case MESA_SHADER_FRAGMENT:
gen.generate_fs_special_vars();
break;
}