mesa: Change "BRIAN PAUL" to "THE AUTHORS" in license text.
[mesa.git] / src / mesa / program / program.h
index 1f1d6140255e82d16b0b21f775d672aecec94c25..01e38dd0f19bf98214778b06fb464ef51274ec48 100644 (file)
@@ -17,7 +17,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
@@ -89,11 +89,20 @@ extern struct gl_program *
 _mesa_lookup_program(struct gl_context *ctx, GLuint id);
 
 extern void
+_mesa_reference_program_(struct gl_context *ctx,
+                         struct gl_program **ptr,
+                         struct gl_program *prog);
+
+static inline void
 _mesa_reference_program(struct gl_context *ctx,
                         struct gl_program **ptr,
-                        struct gl_program *prog);
+                        struct gl_program *prog)
+{
+   if (*ptr != prog)
+      _mesa_reference_program_(ctx, ptr, prog);
+}
 
-static INLINE void
+static inline void
 _mesa_reference_vertprog(struct gl_context *ctx,
                          struct gl_vertex_program **ptr,
                          struct gl_vertex_program *prog)
@@ -102,7 +111,7 @@ _mesa_reference_vertprog(struct gl_context *ctx,
                            (struct gl_program *) prog);
 }
 
-static INLINE void
+static inline void
 _mesa_reference_fragprog(struct gl_context *ctx,
                          struct gl_fragment_program **ptr,
                          struct gl_fragment_program *prog)
@@ -111,7 +120,7 @@ _mesa_reference_fragprog(struct gl_context *ctx,
                            (struct gl_program *) prog);
 }
 
-static INLINE void
+static inline void
 _mesa_reference_geomprog(struct gl_context *ctx,
                          struct gl_geometry_program **ptr,
                          struct gl_geometry_program *prog)
@@ -123,21 +132,21 @@ _mesa_reference_geomprog(struct gl_context *ctx,
 extern struct gl_program *
 _mesa_clone_program(struct gl_context *ctx, const struct gl_program *prog);
 
-static INLINE struct gl_vertex_program *
+static inline struct gl_vertex_program *
 _mesa_clone_vertex_program(struct gl_context *ctx,
                            const struct gl_vertex_program *prog)
 {
    return (struct gl_vertex_program *) _mesa_clone_program(ctx, &prog->Base);
 }
 
-static INLINE struct gl_geometry_program *
+static inline struct gl_geometry_program *
 _mesa_clone_geometry_program(struct gl_context *ctx,
                              const struct gl_geometry_program *prog)
 {
    return (struct gl_geometry_program *) _mesa_clone_program(ctx, &prog->Base);
 }
 
-static INLINE struct gl_fragment_program *
+static inline struct gl_fragment_program *
 _mesa_clone_fragment_program(struct gl_context *ctx,
                              const struct gl_fragment_program *prog)
 {
@@ -168,19 +177,17 @@ _mesa_find_free_register(const GLboolean used[],
 
 extern GLboolean
 _mesa_valid_register_index(const struct gl_context *ctx,
-                           GLuint shaderType,
+                           gl_shader_type shaderType,
                            gl_register_file file, GLint index);
 
 extern void
 _mesa_postprocess_program(struct gl_context *ctx, struct gl_program *prog);
 
-/* keep these in the same order as TGSI_PROCESSOR_* */
 
-static INLINE GLuint
+static inline GLuint
 _mesa_program_target_to_index(GLenum v)
 {
-   switch(v)
-   {
+   switch (v) {
    case GL_VERTEX_PROGRAM_ARB:
       return MESA_SHADER_VERTEX;
    case GL_FRAGMENT_PROGRAM_ARB:
@@ -193,13 +200,13 @@ _mesa_program_target_to_index(GLenum v)
    }
 }
 
-static INLINE GLenum
+static inline GLenum
 _mesa_program_index_to_target(GLuint i)
 {
-   GLenum enums[MESA_SHADER_TYPES] = {
-         GL_VERTEX_PROGRAM_ARB,
-         GL_FRAGMENT_PROGRAM_ARB,
-         GL_GEOMETRY_PROGRAM_NV,
+   static const GLenum enums[MESA_SHADER_TYPES] = {
+      GL_VERTEX_PROGRAM_ARB,
+      GL_FRAGMENT_PROGRAM_ARB,
+      GL_GEOMETRY_PROGRAM_NV,
    };
    if(i >= MESA_SHADER_TYPES)
       return 0;
@@ -207,4 +214,46 @@ _mesa_program_index_to_target(GLuint i)
       return enums[i];
 }
 
+
+/* Cast wrappers from gl_program to gl_vertex/geometry/fragment_program */
+
+static inline struct gl_fragment_program *
+gl_fragment_program(struct gl_program *prog)
+{
+   return (struct gl_fragment_program *) prog;
+}
+
+static inline const struct gl_fragment_program *
+gl_fragment_program_const(const struct gl_program *prog)
+{
+   return (const struct gl_fragment_program *) prog;
+}
+
+
+static inline struct gl_vertex_program *
+gl_vertex_program(struct gl_program *prog)
+{
+   return (struct gl_vertex_program *) prog;
+}
+
+static inline const struct gl_vertex_program *
+gl_vertex_program_const(const struct gl_program *prog)
+{
+   return (const struct gl_vertex_program *) prog;
+}
+
+
+static inline struct gl_geometry_program *
+gl_geometry_program(struct gl_program *prog)
+{
+   return (struct gl_geometry_program *) prog;
+}
+
+static inline const struct gl_geometry_program *
+gl_geometry_program_const(const struct gl_program *prog)
+{
+   return (const struct gl_geometry_program *) prog;
+}
+
+
 #endif /* PROGRAM_H */