glsl: Change _mesa_glsl_parse_state ctor to use gl_shader_stage enum.
authorPaul Berry <stereotype441@gmail.com>
Tue, 7 Jan 2014 17:46:10 +0000 (09:46 -0800)
committerPaul Berry <stereotype441@gmail.com>
Wed, 8 Jan 2014 15:31:49 +0000 (07:31 -0800)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
v2: Also rename "target" param to "stage".

Reviewed-by: Brian Paul <brianp@vmware.com>
src/glsl/glsl_parser_extras.cpp
src/glsl/glsl_parser_extras.h
src/glsl/main.cpp
src/glsl/test_optpass.cpp
src/glsl/tests/builtin_variable_test.cpp
src/mesa/main/ff_fragment_shader.cpp

index 0031e15d7228391c15a3c8186e20d7e89accf633..ce8279f7b547f9231ede83e7f4056da779fbc442 100644 (file)
@@ -54,14 +54,12 @@ static unsigned known_desktop_glsl_versions[] =
 
 
 _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
-                                              GLenum target, void *mem_ctx)
+                                              gl_shader_stage stage,
+                                               void *mem_ctx)
    : ctx(_ctx), switch_state()
 {
-   switch (target) {
-   case GL_VERTEX_SHADER:   this->stage = MESA_SHADER_VERTEX; break;
-   case GL_FRAGMENT_SHADER: this->stage = MESA_SHADER_FRAGMENT; break;
-   case GL_GEOMETRY_SHADER: this->stage = MESA_SHADER_GEOMETRY; break;
-   }
+   assert(stage < MESA_SHADER_STAGES);
+   this->stage = stage;
 
    this->scanner = NULL;
    this->translation_unit.make_empty();
@@ -1479,7 +1477,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
                           bool dump_ast, bool dump_hir)
 {
    struct _mesa_glsl_parse_state *state =
-      new(shader) _mesa_glsl_parse_state(ctx, shader->Type, shader);
+      new(shader) _mesa_glsl_parse_state(ctx, shader->Stage, shader);
    const char *source = shader->Source;
 
    state->error = glcpp_preprocess(state, &source, &state->info_log,
index 197f337529eac0e0872829dbe8453c24b4b84648..6572488e033115a7018722c010a4edea804371ec 100644 (file)
@@ -68,7 +68,7 @@ extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
 
 
 struct _mesa_glsl_parse_state {
-   _mesa_glsl_parse_state(struct gl_context *_ctx, GLenum target,
+   _mesa_glsl_parse_state(struct gl_context *_ctx, gl_shader_stage stage,
                          void *mem_ctx);
 
    DECLARE_RALLOC_CXX_OPERATORS(_mesa_glsl_parse_state);
index 3260c44710f1067ab5018d8dad73df69c8c33a3a..736689eb75cb09293a4a9ae70447bcba486a9270 100644 (file)
@@ -276,7 +276,7 @@ void
 compile_shader(struct gl_context *ctx, struct gl_shader *shader)
 {
    struct _mesa_glsl_parse_state *state =
-      new(shader) _mesa_glsl_parse_state(ctx, shader->Type, shader);
+      new(shader) _mesa_glsl_parse_state(ctx, shader->Stage, shader);
 
    _mesa_glsl_compile_shader(ctx, shader, dump_ast, dump_hir);
 
index bdb1e8ffdebdb8ab20cf2b2c0dd27f43b7d7da74..1a15f3c63aeea48fe29ee56884b00042c946636a 100644 (file)
@@ -209,7 +209,7 @@ int test_optpass(int argc, char **argv)
    string input = read_stdin_to_eof();
 
    struct _mesa_glsl_parse_state *state
-      = new(shader) _mesa_glsl_parse_state(ctx, shader->Type, shader);
+      = new(shader) _mesa_glsl_parse_state(ctx, shader->Stage, shader);
 
    if (input_format_ir) {
       shader->ir = new(shader) exec_list;
index 9b4a097b1e4b1477c482f1a16e48f6699d400e2f..3fdfce57d4f34ee25d27c0e6af89d0eb0317974e 100644 (file)
@@ -68,7 +68,7 @@ common_builtin::SetUp()
    this->shader->Stage = _mesa_shader_enum_to_shader_stage(this->shader_type);
 
    this->state =
-      new(mem_ctx) _mesa_glsl_parse_state(&this->ctx, this->shader->Type,
+      new(mem_ctx) _mesa_glsl_parse_state(&this->ctx, this->shader->Stage,
                                           this->shader);
 
    _mesa_glsl_initialize_types(this->state);
index ba6258d89057bff83fa7fbc705c30c120b0a7d30..00ca0255899963c0f3741ef6448e92dd4d828b0f 100644 (file)
@@ -1296,7 +1296,7 @@ create_new_program(struct gl_context *ctx, struct state_key *key)
    p.mem_ctx = ralloc_context(NULL);
    p.shader = ctx->Driver.NewShader(ctx, 0, GL_FRAGMENT_SHADER);
    p.shader->ir = new(p.shader) exec_list;
-   state = new(p.shader) _mesa_glsl_parse_state(ctx, GL_FRAGMENT_SHADER,
+   state = new(p.shader) _mesa_glsl_parse_state(ctx, MESA_SHADER_FRAGMENT,
                                                p.shader);
    p.shader->symbols = state->symbols;
    p.top_instructions = p.shader->ir;