In my early preparations for working on compute shaders, I've run into some stumbling blocks due to the way the GLSL compiler keeps track of which pipeline stage a given shader is being compiled for.
In some places, it uses a GLenum to store values like GL_VERTEX_SHADER, GL_GEOMETRY_SHADER, or GL_COMPUTE_SHADER. In a small minority of places, it uses a GLenum to store values like GL_VERTEX_PROGRAM_ARB, GL_FRAGMENT_PROGRAM_ARB, or GL_GEOMETRY_PROGRAM_NV. In other places, it uses the enum gl_shader_type, which uses the values 0, 1, and 2 to represent vertex shaders, geometry shaders, and fragment shaders, respectively. To make matters worse, the functions for converting between these representations are inconsistenly named, so when it's necessary to convert from one to another, it's difficult to know which function to call. This patch series attempts to clean all that up by adopting a more consistent nomenclature, and preferring to use the gl_shader_type enum inside the shader compiler. There are three advantages of preferring gl_shader_type over the GLenums: 1. When switching on the shader type, the compiler will warn if one of the enum values is unhandled. 2. It can be used to index into an array of shader stages. 3. It avoids uncertainty between the use of GL_*_SHADER enums and GL_*_PROGRAM enums. The series also renames gl_shader_type to gl_shader_stage to emphasize that this enum represents shader stages in the order in which they appear in the pipeline (a fact which the linker takes advantage of). An additional advantage of this name change is that it makes it easier to make the nomenclature consistent, because the term "stage" isn't used very much in other parts of Mesa. [PATCH 1/7] mesa: Clean up nomenclature for pipeline stages. [PATCH 2/7] mesa: Store gl_shader_stage enum in gl_shader objects. [PATCH 3/7] glsl: Change _mesa_glsl_parse_state ctor to use gl_shader_stage enum. [PATCH 4/7] glsl: Make more use of gl_shader_stage enum in link_varyings.cpp. [PATCH 5/7] glsl: Make more use of gl_shader_stage enum in lower_clip_distance.cpp. [PATCH 6/7] glsl: Make more use of gl_shader_stage enum in ir_set_program_inouts.cpp. [PATCH 7/7] mesa: Remove _mesa_progshader_enum_to_string(), which is no longer used. _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev