[Mesa-dev] [PATCH 3/7] glsl: Change _mesa_glsl_parse_state ctor to use gl_shader_stage enum.

Brian Paul brianp at vmware.com
Tue Jan 7 15:06:31 PST 2014


On 01/07/2014 03:13 PM, Paul Berry wrote:
> ---
>   src/glsl/glsl_parser_extras.cpp          | 12 +++++-------
>   src/glsl/glsl_parser_extras.h            |  2 +-
>   src/glsl/main.cpp                        |  2 +-
>   src/glsl/test_optpass.cpp                |  2 +-
>   src/glsl/tests/builtin_variable_test.cpp |  2 +-
>   src/mesa/main/ff_fragment_shader.cpp     |  2 +-
>   6 files changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
> index bdd8bf4..f9aa1d6 100644
> --- a/src/glsl/glsl_parser_extras.cpp
> +++ b/src/glsl/glsl_parser_extras.cpp
> @@ -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 target,

s/target/stage/ ??


> +                                               void *mem_ctx)
>      : ctx(_ctx), switch_state()
>   {
> -   switch (target) {
> -   case GL_VERTEX_SHADER:   this->target = MESA_SHADER_VERTEX; break;
> -   case GL_FRAGMENT_SHADER: this->target = MESA_SHADER_FRAGMENT; break;
> -   case GL_GEOMETRY_SHADER: this->target = MESA_SHADER_GEOMETRY; break;
> -   }
> +   assert(target < MESA_SHADER_STAGES);
> +   this->target = target;
>
>      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,
> diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
> index a9c5117..2a7ae3d 100644
> --- a/src/glsl/glsl_parser_extras.h
> +++ b/src/glsl/glsl_parser_extras.h
> @@ -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 target,

s/target/stage/


>   			  void *mem_ctx);
>
>      DECLARE_RALLOC_CXX_OPERATORS(_mesa_glsl_parse_state);
> diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp
> index 3260c44..736689e 100644
> --- a/src/glsl/main.cpp
> +++ b/src/glsl/main.cpp
> @@ -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);
>
> diff --git a/src/glsl/test_optpass.cpp b/src/glsl/test_optpass.cpp
> index bdb1e8f..1a15f3c 100644
> --- a/src/glsl/test_optpass.cpp
> +++ b/src/glsl/test_optpass.cpp
> @@ -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;
> diff --git a/src/glsl/tests/builtin_variable_test.cpp b/src/glsl/tests/builtin_variable_test.cpp
> index 9b4a097..3fdfce5 100644
> --- a/src/glsl/tests/builtin_variable_test.cpp
> +++ b/src/glsl/tests/builtin_variable_test.cpp
> @@ -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);
> diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
> index ba6258d..00ca025 100644
> --- a/src/mesa/main/ff_fragment_shader.cpp
> +++ b/src/mesa/main/ff_fragment_shader.cpp
> @@ -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;
>



More information about the mesa-dev mailing list