aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/glsl')
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp10
-rw-r--r--mesalib/src/glsl/builtin_type_macros.h2
-rw-r--r--mesalib/src/glsl/glcpp/glcpp-lex.l79
-rw-r--r--mesalib/src/glsl/glcpp/glcpp-parse.y24
-rw-r--r--mesalib/src/glsl/glcpp/glcpp.h2
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.cpp17
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.h7
-rw-r--r--mesalib/src/glsl/link_atomics.cpp15
-rw-r--r--mesalib/src/glsl/link_varyings.cpp24
-rw-r--r--mesalib/src/glsl/linker.cpp41
10 files changed, 153 insertions, 68 deletions
diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp
index 3bc181e87..91810f985 100644
--- a/mesalib/src/glsl/ast_to_hir.cpp
+++ b/mesalib/src/glsl/ast_to_hir.cpp
@@ -2110,7 +2110,7 @@ validate_explicit_location(const struct ast_type_qualifier *qual,
_mesa_glsl_error(loc, state,
"%s cannot be given an explicit location in %s shader",
mode_string(var),
- _mesa_glsl_shader_target_name(state->target));
+ _mesa_shader_type_to_string(state->target));
} else {
var->data.explicit_location = true;
@@ -2188,7 +2188,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
_mesa_glsl_error(loc, state,
"`attribute' variables may not be declared in the "
"%s shader",
- _mesa_glsl_shader_target_name(state->target));
+ _mesa_shader_type_to_string(state->target));
}
/* Section 6.1.1 (Function Calling Conventions) of the GLSL 1.10 spec says:
@@ -2599,7 +2599,7 @@ process_initializer(ir_variable *var, ast_declaration *decl,
if ((var->data.mode == ir_var_shader_in) && (state->current_function == NULL)) {
_mesa_glsl_error(& initializer_loc, state,
"cannot initialize %s shader input / %s",
- _mesa_glsl_shader_target_name(state->target),
+ _mesa_shader_type_to_string(state->target),
(state->target == MESA_SHADER_VERTEX)
? "attribute" : "varying");
}
@@ -4890,7 +4890,7 @@ ast_interface_block::hir(exec_list *instructions,
_mesa_glsl_error(&loc, state,
"redeclaration of gl_PerVertex input not allowed "
"in the %s shader",
- _mesa_glsl_shader_target_name(state->target));
+ _mesa_shader_type_to_string(state->target));
}
if (this->instance_name == NULL ||
strcmp(this->instance_name, "gl_in") != 0 || !this->is_array) {
@@ -4907,7 +4907,7 @@ ast_interface_block::hir(exec_list *instructions,
_mesa_glsl_error(&loc, state,
"redeclaration of gl_PerVertex output not "
"allowed in the %s shader",
- _mesa_glsl_shader_target_name(state->target));
+ _mesa_shader_type_to_string(state->target));
}
if (this->instance_name != NULL) {
_mesa_glsl_error(&loc, state,
diff --git a/mesalib/src/glsl/builtin_type_macros.h b/mesalib/src/glsl/builtin_type_macros.h
index 263fd83ff..06b4dbd0f 100644
--- a/mesalib/src/glsl/builtin_type_macros.h
+++ b/mesalib/src/glsl/builtin_type_macros.h
@@ -91,7 +91,7 @@ DECL_TYPE(isampler2DMSArray, GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, GLSL_SAMPLER_D
DECL_TYPE(usampler1D, GL_UNSIGNED_INT_SAMPLER_1D, GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_UINT)
DECL_TYPE(usampler2D, GL_UNSIGNED_INT_SAMPLER_2D, GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_UINT)
DECL_TYPE(usampler3D, GL_UNSIGNED_INT_SAMPLER_3D, GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_UINT)
-DECL_TYPE(usamplerCube, GL_INT_SAMPLER_CUBE, GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_UINT)
+DECL_TYPE(usamplerCube, GL_UNSIGNED_INT_SAMPLER_CUBE, GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_UINT)
DECL_TYPE(usampler1DArray, GL_UNSIGNED_INT_SAMPLER_1D_ARRAY, GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_UINT)
DECL_TYPE(usampler2DArray, GL_UNSIGNED_INT_SAMPLER_2D_ARRAY, GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_UINT)
DECL_TYPE(usamplerCubeArray, GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY, GLSL_SAMPLER_DIM_CUBE, 0, 1, GLSL_TYPE_UINT)
diff --git a/mesalib/src/glsl/glcpp/glcpp-lex.l b/mesalib/src/glsl/glcpp/glcpp-lex.l
index a029f6203..f1fa192c5 100644
--- a/mesalib/src/glsl/glcpp/glcpp-lex.l
+++ b/mesalib/src/glsl/glcpp/glcpp-lex.l
@@ -67,7 +67,7 @@ void glcpp_set_column (int column_no , yyscan_t yyscanner);
%option stack
%option never-interactive
-%x DONE COMMENT UNREACHABLE SKIP DEFINE
+%x DONE COMMENT UNREACHABLE SKIP DEFINE NEWLINE_CATCHUP
SPACE [[:space:]]
NONSPACE [^[:space:]]
@@ -92,13 +92,62 @@ OCTAL_INTEGER 0[0-7]*[uU]?
HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
%%
- /* Implicitly switch between SKIP and INITIAL (non-skipping);
- * don't switch if some other state was explicitly set.
- */
+
glcpp_parser_t *parser = yyextra;
- if (YY_START == 0 || YY_START == SKIP) {
- if (parser->lexing_if || parser->skip_stack == NULL || parser->skip_stack->type == SKIP_NO_SKIP) {
- BEGIN 0;
+
+ /* When we lex a multi-line comment, we replace it (as
+ * specified) with a single space. But if the comment spanned
+ * multiple lines, then subsequent parsing stages will not
+ * count correct line numbers. To avoid this problem we keep
+ * track of all newlines that were commented out by a
+ * multi-line comment, and we emit a NEWLINE token for each at
+ * the next legal opportunity, (which is when the lexer would
+ * be emitting a NEWLINE token anyway).
+ */
+ if (YY_START == NEWLINE_CATCHUP) {
+ if (parser->commented_newlines)
+ parser->commented_newlines--;
+ if (parser->commented_newlines == 0)
+ BEGIN INITIAL;
+ return NEWLINE;
+ }
+
+ /* The handling of the SKIP vs INITIAL start states requires
+ * some special handling. Typically, a lexer would change
+ * start states with statements like "BEGIN SKIP" within the
+ * lexer rules. We can't get away with that here, since we
+ * need the parser to actually evaluate expressions for
+ * directives like "#if".
+ *
+ * So, here, in code that will be executed on every call to
+ * the lexer,and before any rules, we examine the skip_stack
+ * as set by the parser to know whether to change from INITIAL
+ * to SKIP or from SKIP back to INITIAL.
+ *
+ * Three cases cause us to switch out of the SKIP state and
+ * back to the INITIAL state:
+ *
+ * 1. The top of the skip_stack is of type SKIP_NO_SKIP
+ * This means we're still evaluating some #if
+ * hierarchy, but we're on a branch of it where
+ * content should not be skipped (such as "#if 1" or
+ * "#else" or so).
+ *
+ * 2. The skip_stack is NULL meaning that we've reached
+ * the last #endif.
+ *
+ * 3. The lexing_if bit is set. This indicates that we
+ * are lexing the expression following an "#if" of
+ * "#elif". Even inside an "#if 0" we need to lex this
+ * expression so the parser can correctly update the
+ * skip_stack state.
+ */
+ if (YY_START == INITIAL || YY_START == SKIP) {
+ if (parser->lexing_if ||
+ parser->skip_stack == NULL ||
+ parser->skip_stack->type == SKIP_NO_SKIP)
+ {
+ BEGIN INITIAL;
} else {
BEGIN SKIP;
}
@@ -106,14 +155,16 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
/* Single-line comments */
"//"[^\n]* {
+ if (parser->commented_newlines)
+ BEGIN NEWLINE_CATCHUP;
}
/* Multi-line comments */
"/*" { yy_push_state(COMMENT, yyscanner); }
<COMMENT>[^*\n]*
-<COMMENT>[^*\n]*\n { yylineno++; yycolumn = 0; return NEWLINE; }
+<COMMENT>[^*\n]*\n { yylineno++; yycolumn = 0; parser->commented_newlines++; }
<COMMENT>"*"+[^*/\n]*
-<COMMENT>"*"+[^*/\n]*\n { yylineno++; yycolumn = 0; return NEWLINE; }
+<COMMENT>"*"+[^*/\n]*\n { yylineno++; yycolumn = 0; parser->commented_newlines++; }
<COMMENT>"*"+"/" {
yy_pop_state(yyscanner);
if (yyextra->space_tokens)
@@ -129,6 +180,8 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
/* glcpp doesn't handle #extension, #version, or #pragma directives.
* Simply pass them through to the main compiler's lexer/parser. */
{HASH}(extension|pragma)[^\n]+ {
+ if (parser->commented_newlines)
+ BEGIN NEWLINE_CATCHUP;
yylval->str = ralloc_strdup (yyextra, yytext);
yylineno++;
yycolumn = 0;
@@ -175,7 +228,10 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
}
}
-<SKIP>[^\n] ;
+<SKIP>[^\n] {
+ if (parser->commented_newlines)
+ BEGIN NEWLINE_CATCHUP;
+}
{HASH}error.* {
char *p;
@@ -290,6 +346,9 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
}
<SKIP,INITIAL>\n {
+ if (parser->commented_newlines) {
+ BEGIN NEWLINE_CATCHUP;
+ }
yyextra->lexing_if = 0;
yylineno++;
yycolumn = 0;
diff --git a/mesalib/src/glsl/glcpp/glcpp-parse.y b/mesalib/src/glsl/glcpp/glcpp-parse.y
index 7edc27488..ef084b639 100644
--- a/mesalib/src/glsl/glcpp/glcpp-parse.y
+++ b/mesalib/src/glsl/glcpp/glcpp-parse.y
@@ -310,6 +310,11 @@ control_line:
_glcpp_parser_expand_and_lex_from (parser,
ELIF_EXPANDED, $2);
}
+ else if (parser->skip_stack &&
+ parser->skip_stack->has_else)
+ {
+ glcpp_error(& @1, parser, "#elif after #else");
+ }
else
{
_glcpp_parser_skip_stack_change_if (parser, & @1,
@@ -324,6 +329,11 @@ control_line:
{
glcpp_error(& @1, parser, "#elif with no expression");
}
+ else if (parser->skip_stack &&
+ parser->skip_stack->has_else)
+ {
+ glcpp_error(& @1, parser, "#elif after #else");
+ }
else
{
_glcpp_parser_skip_stack_change_if (parser, & @1,
@@ -332,7 +342,17 @@ control_line:
}
}
| HASH_ELSE {
- _glcpp_parser_skip_stack_change_if (parser, & @1, "else", 1);
+ if (parser->skip_stack &&
+ parser->skip_stack->has_else)
+ {
+ glcpp_error(& @1, parser, "multiple #else");
+ }
+ else
+ {
+ _glcpp_parser_skip_stack_change_if (parser, & @1, "else", 1);
+ if (parser->skip_stack)
+ parser->skip_stack->has_else = true;
+ }
} NEWLINE
| HASH_ENDIF {
_glcpp_parser_skip_stack_pop (parser, & @1);
@@ -1164,6 +1184,7 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api)
parser->newline_as_space = 0;
parser->in_control_line = 0;
parser->paren_count = 0;
+ parser->commented_newlines = 0;
parser->skip_stack = NULL;
@@ -2024,6 +2045,7 @@ _glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
node->type = SKIP_TO_ENDIF;
}
+ node->has_else = false;
node->next = parser->skip_stack;
parser->skip_stack = node;
}
diff --git a/mesalib/src/glsl/glcpp/glcpp.h b/mesalib/src/glsl/glcpp/glcpp.h
index 8aaa551d1..85f3fdcd2 100644
--- a/mesalib/src/glsl/glcpp/glcpp.h
+++ b/mesalib/src/glsl/glcpp/glcpp.h
@@ -153,6 +153,7 @@ typedef enum skip_type {
typedef struct skip_node {
skip_type_t type;
+ bool has_else;
YYLTYPE loc; /* location of the initial #if/#elif/... */
struct skip_node *next;
} skip_node_t;
@@ -172,6 +173,7 @@ struct glcpp_parser {
int newline_as_space;
int in_control_line;
int paren_count;
+ int commented_newlines;
skip_node_t *skip_stack;
token_list_t *lex_from_list;
token_node_t *lex_from_node;
diff --git a/mesalib/src/glsl/glsl_parser_extras.cpp b/mesalib/src/glsl/glsl_parser_extras.cpp
index 5f19368d8..fc9a8b204 100644
--- a/mesalib/src/glsl/glsl_parser_extras.cpp
+++ b/mesalib/src/glsl/glsl_parser_extras.cpp
@@ -334,16 +334,15 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version,
extern "C" {
/**
- * The most common use of _mesa_glsl_shader_target_name(), which is
- * shared with C code in Mesa core to translate a GLenum to a short
- * shader stage name in debug printouts.
+ * Translate a GLenum to a short shader stage name for debug printouts and
+ * error messages.
*
* It recognizes the PROGRAM variants of the names so it can be used
* with a struct gl_program->Target, not just a struct
* gl_shader->Type.
*/
const char *
-_mesa_glsl_shader_target_name(GLenum type)
+_mesa_shader_enum_to_string(GLenum type)
{
switch (type) {
case GL_VERTEX_SHADER:
@@ -363,11 +362,11 @@ _mesa_glsl_shader_target_name(GLenum type)
} /* extern "C" */
/**
- * Overloaded C++ variant usable within the compiler for translating
- * our internal enum into short stage names.
+ * Translate a gl_shader_type to a short shader stage name for debug printouts
+ * and error messages.
*/
const char *
-_mesa_glsl_shader_target_name(gl_shader_type target)
+_mesa_shader_type_to_string(unsigned target)
{
switch (target) {
case MESA_SHADER_VERTEX: return "vertex";
@@ -651,11 +650,11 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
if (behavior == extension_require) {
_mesa_glsl_error(name_locp, state, fmt,
- name, _mesa_glsl_shader_target_name(state->target));
+ name, _mesa_shader_type_to_string(state->target));
return false;
} else {
_mesa_glsl_warning(name_locp, state, fmt,
- name, _mesa_glsl_shader_target_name(state->target));
+ name, _mesa_shader_type_to_string(state->target));
}
}
}
diff --git a/mesalib/src/glsl/glsl_parser_extras.h b/mesalib/src/glsl/glsl_parser_extras.h
index 622ddbac7..7b013fa6d 100644
--- a/mesalib/src/glsl/glsl_parser_extras.h
+++ b/mesalib/src/glsl/glsl_parser_extras.h
@@ -422,10 +422,11 @@ extern bool _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
_mesa_glsl_parse_state *state);
/**
- * Get the textual name of the specified shader target
+ * Get the textual name of the specified shader target (which is a
+ * gl_shader_type).
*/
extern const char *
-_mesa_glsl_shader_target_name(gl_shader_type target);
+_mesa_shader_type_to_string(unsigned target);
#endif /* __cplusplus */
@@ -439,7 +440,7 @@ extern "C" {
#endif
extern const char *
-_mesa_glsl_shader_target_name(GLenum type);
+_mesa_shader_enum_to_string(GLenum type);
extern int glcpp_preprocess(void *ctx, const char **shader, char **info_log,
const struct gl_extensions *extensions, struct gl_context *gl_ctx);
diff --git a/mesalib/src/glsl/link_atomics.cpp b/mesalib/src/glsl/link_atomics.cpp
index 33903ad54..603329c50 100644
--- a/mesalib/src/glsl/link_atomics.cpp
+++ b/mesalib/src/glsl/link_atomics.cpp
@@ -21,6 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include "glsl_parser_extras.h"
#include "ir.h"
#include "ir_uniform.h"
#include "linker.h"
@@ -213,20 +214,18 @@ void
link_check_atomic_counter_resources(struct gl_context *ctx,
struct gl_shader_program *prog)
{
- STATIC_ASSERT(MESA_SHADER_TYPES == 3);
- static const char *shader_names[MESA_SHADER_TYPES] = {
- "vertex", "geometry", "fragment"
- };
- const unsigned max_atomic_counters[MESA_SHADER_TYPES] = {
+ const unsigned max_atomic_counters[] = {
ctx->Const.VertexProgram.MaxAtomicCounters,
ctx->Const.GeometryProgram.MaxAtomicCounters,
ctx->Const.FragmentProgram.MaxAtomicCounters
};
- const unsigned max_atomic_buffers[MESA_SHADER_TYPES] = {
+ STATIC_ASSERT(Elements(max_atomic_counters) == MESA_SHADER_TYPES);
+ const unsigned max_atomic_buffers[] = {
ctx->Const.VertexProgram.MaxAtomicBuffers,
ctx->Const.GeometryProgram.MaxAtomicBuffers,
ctx->Const.FragmentProgram.MaxAtomicBuffers
};
+ STATIC_ASSERT(Elements(max_atomic_buffers) == MESA_SHADER_TYPES);
unsigned num_buffers;
active_atomic_buffer *const abs =
find_active_atomic_counters(ctx, prog, &num_buffers);
@@ -260,11 +259,11 @@ link_check_atomic_counter_resources(struct gl_context *ctx,
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
if (atomic_counters[i] > max_atomic_counters[i])
linker_error(prog, "Too many %s shader atomic counters",
- shader_names[i]);
+ _mesa_shader_type_to_string(i));
if (atomic_buffers[i] > max_atomic_buffers[i])
linker_error(prog, "Too many %s shader atomic counter buffers",
- shader_names[i]);
+ _mesa_shader_type_to_string(i));
}
if (total_atomic_counters > ctx->Const.MaxCombinedAtomicCounters)
diff --git a/mesalib/src/glsl/link_varyings.cpp b/mesalib/src/glsl/link_varyings.cpp
index 229a4cb85..98f902ca4 100644
--- a/mesalib/src/glsl/link_varyings.cpp
+++ b/mesalib/src/glsl/link_varyings.cpp
@@ -82,10 +82,10 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
linker_error(prog,
"%s shader output `%s' declared as type `%s', "
"but %s shader input declared as type `%s'\n",
- _mesa_glsl_shader_target_name(producer_type),
+ _mesa_shader_enum_to_string(producer_type),
output->name,
output->type->name,
- _mesa_glsl_shader_target_name(consumer_type),
+ _mesa_shader_enum_to_string(consumer_type),
input->type->name);
return;
}
@@ -97,10 +97,10 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
linker_error(prog,
"%s shader output `%s' %s centroid qualifier, "
"but %s shader input %s centroid qualifier\n",
- _mesa_glsl_shader_target_name(producer_type),
+ _mesa_shader_enum_to_string(producer_type),
output->name,
(output->data.centroid) ? "has" : "lacks",
- _mesa_glsl_shader_target_name(consumer_type),
+ _mesa_shader_enum_to_string(consumer_type),
(input->data.centroid) ? "has" : "lacks");
return;
}
@@ -109,10 +109,10 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
linker_error(prog,
"%s shader output `%s' %s sample qualifier, "
"but %s shader input %s sample qualifier\n",
- _mesa_glsl_shader_target_name(producer_type),
+ _mesa_shader_enum_to_string(producer_type),
output->name,
(output->data.sample) ? "has" : "lacks",
- _mesa_glsl_shader_target_name(consumer_type),
+ _mesa_shader_enum_to_string(consumer_type),
(input->data.sample) ? "has" : "lacks");
return;
}
@@ -121,10 +121,10 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
linker_error(prog,
"%s shader output `%s' %s invariant qualifier, "
"but %s shader input %s invariant qualifier\n",
- _mesa_glsl_shader_target_name(producer_type),
+ _mesa_shader_enum_to_string(producer_type),
output->name,
(output->data.invariant) ? "has" : "lacks",
- _mesa_glsl_shader_target_name(consumer_type),
+ _mesa_shader_enum_to_string(consumer_type),
(input->data.invariant) ? "has" : "lacks");
return;
}
@@ -135,10 +135,10 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
"interpolation qualifier, "
"but %s shader input specifies %s "
"interpolation qualifier\n",
- _mesa_glsl_shader_target_name(producer_type),
+ _mesa_shader_enum_to_string(producer_type),
output->name,
interpolation_string(output->data.interpolation),
- _mesa_glsl_shader_target_name(consumer_type),
+ _mesa_shader_enum_to_string(consumer_type),
interpolation_string(input->data.interpolation));
return;
}
@@ -1217,9 +1217,9 @@ assign_varying_locations(struct gl_context *ctx,
linker_error(prog, "%s shader varying %s not written "
"by %s shader\n.",
- _mesa_glsl_shader_target_name(consumer->Type),
+ _mesa_shader_enum_to_string(consumer->Type),
var->name,
- _mesa_glsl_shader_target_name(producer->Type));
+ _mesa_shader_enum_to_string(producer->Type));
}
/* An 'in' variable is only really a shader input if its
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index a6133ea9c..a81e10737 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -414,7 +414,7 @@ link_invalidate_variable_locations(exec_list *ir)
* Return false if an error was reported.
*/
static void
-analyze_clip_usage(const char *shader_type, struct gl_shader_program *prog,
+analyze_clip_usage(struct gl_shader_program *prog,
struct gl_shader *shader, GLboolean *UsesClipDistance,
GLuint *ClipDistanceArraySize)
{
@@ -437,7 +437,8 @@ analyze_clip_usage(const char *shader_type, struct gl_shader_program *prog,
clip_distance.run(shader->ir);
if (clip_vertex.variable_found() && clip_distance.variable_found()) {
linker_error(prog, "%s shader writes to both `gl_ClipVertex' "
- "and `gl_ClipDistance'\n", shader_type);
+ "and `gl_ClipDistance'\n",
+ _mesa_shader_enum_to_string(shader->Type));
return;
}
*UsesClipDistance = clip_distance.variable_found();
@@ -501,7 +502,7 @@ validate_vertex_shader_executable(struct gl_shader_program *prog,
}
}
- analyze_clip_usage("vertex", prog, shader, &prog->Vert.UsesClipDistance,
+ analyze_clip_usage(prog, shader, &prog->Vert.UsesClipDistance,
&prog->Vert.ClipDistanceArraySize);
}
@@ -548,7 +549,7 @@ validate_geometry_shader_executable(struct gl_shader_program *prog,
unsigned num_vertices = vertices_per_prim(prog->Geom.InputType);
prog->Geom.VerticesIn = num_vertices;
- analyze_clip_usage("geometry", prog, shader, &prog->Geom.UsesClipDistance,
+ analyze_clip_usage(prog, shader, &prog->Geom.UsesClipDistance,
&prog->Geom.ClipDistanceArraySize);
find_end_primitive_visitor end_primitive;
@@ -1375,7 +1376,7 @@ link_intrastage_shaders(void *mem_ctx,
if (main == NULL) {
linker_error(prog, "%s shader lacks `main'\n",
- _mesa_glsl_shader_target_name(shader_list[0]->Type));
+ _mesa_shader_enum_to_string(shader_list[0]->Type));
return NULL;
}
@@ -1893,33 +1894,35 @@ store_fragdepth_layout(struct gl_shader_program *prog)
static void
check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
{
- static const char *const shader_names[MESA_SHADER_TYPES] = {
- "vertex", "geometry", "fragment"
- };
-
- const unsigned max_samplers[MESA_SHADER_TYPES] = {
+ const unsigned max_samplers[] = {
ctx->Const.VertexProgram.MaxTextureImageUnits,
ctx->Const.GeometryProgram.MaxTextureImageUnits,
ctx->Const.FragmentProgram.MaxTextureImageUnits
};
+ STATIC_ASSERT(Elements(max_samplers) == MESA_SHADER_TYPES);
- const unsigned max_default_uniform_components[MESA_SHADER_TYPES] = {
+ const unsigned max_default_uniform_components[] = {
ctx->Const.VertexProgram.MaxUniformComponents,
ctx->Const.GeometryProgram.MaxUniformComponents,
ctx->Const.FragmentProgram.MaxUniformComponents
};
+ STATIC_ASSERT(Elements(max_default_uniform_components) ==
+ MESA_SHADER_TYPES);
- const unsigned max_combined_uniform_components[MESA_SHADER_TYPES] = {
+ const unsigned max_combined_uniform_components[] = {
ctx->Const.VertexProgram.MaxCombinedUniformComponents,
ctx->Const.GeometryProgram.MaxCombinedUniformComponents,
ctx->Const.FragmentProgram.MaxCombinedUniformComponents
};
+ STATIC_ASSERT(Elements(max_combined_uniform_components) ==
+ MESA_SHADER_TYPES);
- const unsigned max_uniform_blocks[MESA_SHADER_TYPES] = {
+ const unsigned max_uniform_blocks[] = {
ctx->Const.VertexProgram.MaxUniformBlocks,
ctx->Const.GeometryProgram.MaxUniformBlocks,
ctx->Const.FragmentProgram.MaxUniformBlocks
};
+ STATIC_ASSERT(Elements(max_uniform_blocks) == MESA_SHADER_TYPES);
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
struct gl_shader *sh = prog->_LinkedShaders[i];
@@ -1929,7 +1932,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
if (sh->num_samplers > max_samplers[i]) {
linker_error(prog, "Too many %s shader texture samplers",
- shader_names[i]);
+ _mesa_shader_type_to_string(i));
}
if (sh->num_uniform_components > max_default_uniform_components[i]) {
@@ -1938,11 +1941,11 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
"components, but the driver will try to optimize "
"them out; this is non-portable out-of-spec "
"behavior\n",
- shader_names[i]);
+ _mesa_shader_type_to_string(i));
} else {
linker_error(prog, "Too many %s shader default uniform block "
"components",
- shader_names[i]);
+ _mesa_shader_type_to_string(i));
}
}
@@ -1952,10 +1955,10 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
linker_warning(prog, "Too many %s shader uniform components, "
"but the driver will try to optimize them out; "
"this is non-portable out-of-spec behavior\n",
- shader_names[i]);
+ _mesa_shader_type_to_string(i));
} else {
linker_error(prog, "Too many %s shader uniform components",
- shader_names[i]);
+ _mesa_shader_type_to_string(i));
}
}
}
@@ -1979,7 +1982,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
if (blocks[i] > max_uniform_blocks[i]) {
linker_error(prog, "Too many %s uniform blocks (%d/%d)",
- shader_names[i],
+ _mesa_shader_type_to_string(i),
blocks[i],
max_uniform_blocks[i]);
break;