linker: Make invalidate_variable_locations available outside the compilation unit
[profile/ivi/mesa.git] / src / glsl / linker.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright © 2010 Intel Corporation
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24
25 #pragma once
26 #ifndef GLSL_LINKER_H
27 #define GLSL_LINKER_H
28
29 extern bool
30 link_function_calls(gl_shader_program *prog, gl_shader *main,
31                     gl_shader **shader_list, unsigned num_shaders);
32
33 extern void
34 link_invalidate_variable_locations(gl_shader *sh, enum ir_variable_mode mode,
35                                    int generic_base);
36
37 /**
38  * Class for processing all of the leaf fields of an uniform
39  *
40  * Leaves are, roughly speaking, the parts of the uniform that the application
41  * could query with \c glGetUniformLocation (or that could be returned by
42  * \c glGetActiveUniforms).
43  *
44  * Classes my derive from this class to implement specific functionality.
45  * This class only provides the mechanism to iterate over the leaves.  Derived
46  * classes must implement \c ::visit_field and may override \c ::process.
47  */
48 class uniform_field_visitor {
49 public:
50    /**
51     * Begin processing a uniform
52     *
53     * Classes that overload this function should call \c ::process from the
54     * base class to start the recursive processing of the uniform.
55     *
56     * \param var  The uniform variable that is to be processed
57     *
58     * Calls \c ::visit_field for each leaf of the uniform.
59     */
60    void process(ir_variable *var);
61
62 protected:
63    /**
64     * Method invoked for each leaf of the uniform
65     *
66     * \param type  Type of the field.
67     * \param name  Fully qualified name of the field.
68     */
69    virtual void visit_field(const glsl_type *type, const char *name) = 0;
70
71 private:
72    /**
73     * \param name_length  Length of the current name \b not including the
74     *                     terminating \c NUL character.
75     */
76    void recursion(const glsl_type *t, char **name, unsigned name_length);
77 };
78
79 #endif /* GLSL_LINKER_H */