static void generate_110_vs_variables(exec_list *instructions, struct _mesa_glsl_parse_state *state) { for (unsigned i = 0; i < Elements(builtin_core_vs_variables); i++) { add_builtin_variable(instructions, state->symbols, & builtin_core_vs_variables[i]); } for (unsigned i = 0 ; i < Elements(builtin_110_deprecated_vs_variables) ; i++) { add_builtin_variable(instructions, state->symbols, & builtin_110_deprecated_vs_variables[i]); } generate_110_uniforms(instructions, state); /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec: * * "As with all arrays, indices used to subscript gl_TexCoord must * either be an integral constant expressions, or this array must be * re-declared by the shader with a size. The size can be at most * gl_MaxTextureCoords. Using indexes close to 0 may aid the * implementation in preserving varying resources." */ const glsl_type *const vec4_array_type = glsl_type::get_array_instance(glsl_type::vec4_type, 0); add_variable(instructions, state->symbols, "gl_TexCoord", vec4_array_type, ir_var_out, VERT_RESULT_TEX0); generate_ARB_draw_buffers_variables(instructions, state, false, vertex_shader); }
static void generate_130_vs_variables(exec_list *instructions, struct _mesa_glsl_parse_state *state, bool add_deprecated) { generate_120_vs_variables(instructions, state, add_deprecated); for (unsigned i = 0; i < Elements(builtin_130_vs_variables); i++) { add_builtin_variable(instructions, state->symbols, & builtin_130_vs_variables[i]); } generate_130_uniforms(instructions, state); /* From the GLSL 1.30 spec, section 7.1 (Vertex Shader Special * Variables): * * The gl_ClipDistance array is predeclared as unsized and must * be sized by the shader either redeclaring it with a size or * indexing it only with integral constant expressions. * * We represent this in Mesa by initially declaring the array as * size 0. */ const glsl_type *const clip_distance_array_type = glsl_type::get_array_instance(glsl_type::float_type, 0); add_variable(instructions, state->symbols, "gl_ClipDistance", clip_distance_array_type, ir_var_shader_out, VERT_RESULT_CLIP_DIST0); }
/* This function should only be called for ES, not desktop GL. */ static void generate_100ES_fs_variables(exec_list *instructions, struct _mesa_glsl_parse_state *state) { for (unsigned i = 0; i < Elements(builtin_core_fs_variables); i++) { add_builtin_variable(instructions, state->symbols, & builtin_core_fs_variables[i]); } for (unsigned i = 0; i < Elements(builtin_100ES_fs_variables); i++) { add_builtin_variable(instructions, state->symbols, & builtin_100ES_fs_variables[i]); } generate_100ES_uniforms(instructions, state); generate_ARB_draw_buffers_variables(instructions, state, false, fragment_shader); }
static void generate_120_fs_variables(exec_list *instructions, struct _mesa_glsl_parse_state *state) { generate_110_fs_variables(instructions, state); for (unsigned i = 0 ; i < Elements(builtin_120_fs_variables) ; i++) { add_builtin_variable(instructions, state->symbols, & builtin_120_fs_variables[i]); } }
static void generate_300ES_fs_variables(exec_list *instructions, struct _mesa_glsl_parse_state *state) { /* Note: we don't add builtin_core_fs_variables, because it contains * gl_FragColor, which is not in GLSL 3.00 ES. */ for (unsigned i = 0; i < Elements(builtin_300ES_fs_variables); i++) { add_builtin_variable(instructions, state->symbols, & builtin_300ES_fs_variables[i]); } generate_300ES_uniforms(instructions, state); generate_ARB_draw_buffers_variables(instructions, state, false, fragment_shader); }
static void generate_130_vs_variables(exec_list *instructions, struct _mesa_glsl_parse_state *state) { generate_120_vs_variables(instructions, state); for (unsigned i = 0; i < Elements(builtin_130_vs_variables); i++) { add_builtin_variable(instructions, state->symbols, & builtin_130_vs_variables[i]); } const glsl_type *const clip_distance_array_type = glsl_type::get_array_instance(glsl_type::float_type, state->Const.MaxClipPlanes); /* FINISHME: gl_ClipDistance needs a real location assigned. */ add_variable(instructions, state->symbols, "gl_ClipDistance", clip_distance_array_type, ir_var_out, -1); }
static void generate_110_uniforms(exec_list *instructions, struct _mesa_glsl_parse_state *state, bool add_deprecated) { glsl_symbol_table *const symtab = state->symbols; if (add_deprecated) { for (unsigned i = 0 ; i < Elements(builtin_110_deprecated_uniforms) ; i++) { add_builtin_variable(instructions, symtab, & builtin_110_deprecated_uniforms[i]); } } if (add_deprecated) { add_builtin_constant(instructions, symtab, "gl_MaxLights", state->Const.MaxLights); add_builtin_constant(instructions, symtab, "gl_MaxClipPlanes", state->Const.MaxClipPlanes); add_builtin_constant(instructions, symtab, "gl_MaxTextureUnits", state->Const.MaxTextureUnits); add_builtin_constant(instructions, symtab, "gl_MaxTextureCoords", state->Const.MaxTextureCoords); } add_builtin_constant(instructions, symtab, "gl_MaxVertexAttribs", state->Const.MaxVertexAttribs); add_builtin_constant(instructions, symtab, "gl_MaxVertexUniformComponents", state->Const.MaxVertexUniformComponents); add_builtin_constant(instructions, symtab, "gl_MaxVaryingFloats", state->Const.MaxVaryingFloats); add_builtin_constant(instructions, symtab, "gl_MaxVertexTextureImageUnits", state->Const.MaxVertexTextureImageUnits); add_builtin_constant(instructions, symtab, "gl_MaxCombinedTextureImageUnits", state->Const.MaxCombinedTextureImageUnits); add_builtin_constant(instructions, symtab, "gl_MaxTextureImageUnits", state->Const.MaxTextureImageUnits); add_builtin_constant(instructions, symtab, "gl_MaxFragmentUniformComponents", state->Const.MaxFragmentUniformComponents); if (add_deprecated) { const glsl_type *const mat4_array_type = glsl_type::get_array_instance(glsl_type::mat4_type, state->Const.MaxTextureCoords); add_uniform(instructions, symtab, "gl_TextureMatrix", mat4_array_type); add_uniform(instructions, symtab, "gl_TextureMatrixInverse", mat4_array_type); add_uniform(instructions, symtab, "gl_TextureMatrixTranspose", mat4_array_type); add_uniform(instructions, symtab, "gl_TextureMatrixInverseTranspose", mat4_array_type); } add_uniform(instructions, symtab, "gl_DepthRange", symtab->get_type("gl_DepthRangeParameters")); if (add_deprecated) { add_uniform(instructions, symtab, "gl_ClipPlane", glsl_type::get_array_instance(glsl_type::vec4_type, state->Const.MaxClipPlanes)); add_uniform(instructions, symtab, "gl_Point", symtab->get_type("gl_PointParameters")); const glsl_type *const material_parameters_type = symtab->get_type("gl_MaterialParameters"); add_uniform(instructions, symtab, "gl_FrontMaterial", material_parameters_type); add_uniform(instructions, symtab, "gl_BackMaterial", material_parameters_type); const glsl_type *const light_source_array_type = glsl_type::get_array_instance(symtab->get_type("gl_LightSourceParameters"), state->Const.MaxLights); add_uniform(instructions, symtab, "gl_LightSource", light_source_array_type); const glsl_type *const light_model_products_type = symtab->get_type("gl_LightModelProducts"); add_uniform(instructions, symtab, "gl_FrontLightModelProduct", light_model_products_type); add_uniform(instructions, symtab, "gl_BackLightModelProduct", light_model_products_type); const glsl_type *const light_products_type = glsl_type::get_array_instance(symtab->get_type("gl_LightProducts"), state->Const.MaxLights); add_uniform(instructions, symtab, "gl_FrontLightProduct", light_products_type); add_uniform(instructions, symtab, "gl_BackLightProduct", light_products_type); add_uniform(instructions, symtab, "gl_TextureEnvColor", glsl_type::get_array_instance(glsl_type::vec4_type, state->Const.MaxTextureUnits)); const glsl_type *const texcoords_vec4 = glsl_type::get_array_instance(glsl_type::vec4_type, state->Const.MaxTextureCoords); add_uniform(instructions, symtab, "gl_EyePlaneS", texcoords_vec4); add_uniform(instructions, symtab, "gl_EyePlaneT", texcoords_vec4); add_uniform(instructions, symtab, "gl_EyePlaneR", texcoords_vec4); add_uniform(instructions, symtab, "gl_EyePlaneQ", texcoords_vec4); add_uniform(instructions, symtab, "gl_ObjectPlaneS", texcoords_vec4); add_uniform(instructions, symtab, "gl_ObjectPlaneT", texcoords_vec4); add_uniform(instructions, symtab, "gl_ObjectPlaneR", texcoords_vec4); add_uniform(instructions, symtab, "gl_ObjectPlaneQ", texcoords_vec4); add_uniform(instructions, symtab, "gl_Fog", symtab->get_type("gl_FogParameters")); } /* Mesa-internal current attrib state */ const glsl_type *const vert_attribs = glsl_type::get_array_instance(glsl_type::vec4_type, VERT_ATTRIB_MAX); add_uniform(instructions, symtab, "gl_CurrentAttribVertMESA", vert_attribs); const glsl_type *const frag_attribs = glsl_type::get_array_instance(glsl_type::vec4_type, FRAG_ATTRIB_MAX); add_uniform(instructions, symtab, "gl_CurrentAttribFragMESA", frag_attribs); }