1747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick/* -*- c++ -*- */
28fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick/*
38fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick * Copyright © 2010 Intel Corporation
48fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick *
58fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick * Permission is hereby granted, free of charge, to any person obtaining a
68fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick * copy of this software and associated documentation files (the "Software"),
78fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick * to deal in the Software without restriction, including without limitation
88fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick * the rights to use, copy, modify, merge, publish, distribute, sublicense,
98fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick * and/or sell copies of the Software, and to permit persons to whom the
108fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick * Software is furnished to do so, subject to the following conditions:
118fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick *
128fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick * The above copyright notice and this permission notice (including the next
138fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick * paragraph) shall be included in all copies or substantial portions of the
148fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick * Software.
158fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick *
168fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
178fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
188fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
198fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
208fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
218fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
228fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick * DEALINGS IN THE SOFTWARE.
238fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick */
248fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick
258fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick#pragma once
268fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick#ifndef GLSL_LINKER_H
278fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick#define GLSL_LINKER_H
288fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick
298fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanickextern bool
308fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanicklink_function_calls(gl_shader_program *prog, gl_shader *main,
318fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick		    gl_shader **shader_list, unsigned num_shaders);
328fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick
33f6ee7bce65697ea3c6a78a000a49af901ba77c1dIan Romanickextern void
34f6ee7bce65697ea3c6a78a000a49af901ba77c1dIan Romanicklink_invalidate_variable_locations(gl_shader *sh, enum ir_variable_mode mode,
35f6ee7bce65697ea3c6a78a000a49af901ba77c1dIan Romanick				   int generic_base);
36f6ee7bce65697ea3c6a78a000a49af901ba77c1dIan Romanick
3707731ed1692eb5d72110b3c5b693f37e581e3809Ian Romanickextern void
3807731ed1692eb5d72110b3c5b693f37e581e3809Ian Romanicklink_assign_uniform_locations(struct gl_shader_program *prog);
3907731ed1692eb5d72110b3c5b693f37e581e3809Ian Romanick
40a2e623054b5d8eafebc7499efe93e4bceae16eadIan Romanickextern void
41a2e623054b5d8eafebc7499efe93e4bceae16eadIan Romanicklink_set_uniform_initializers(struct gl_shader_program *prog);
42a2e623054b5d8eafebc7499efe93e4bceae16eadIan Romanick
43f609cf782ab5e90ddf045dc4b0da8cebf99be0d1Eric Anholtextern int
44f609cf782ab5e90ddf045dc4b0da8cebf99be0d1Eric Anholtlink_cross_validate_uniform_block(void *mem_ctx,
45f609cf782ab5e90ddf045dc4b0da8cebf99be0d1Eric Anholt				  struct gl_uniform_block **linked_blocks,
46f609cf782ab5e90ddf045dc4b0da8cebf99be0d1Eric Anholt				  unsigned int *num_linked_blocks,
47f609cf782ab5e90ddf045dc4b0da8cebf99be0d1Eric Anholt				  struct gl_uniform_block *new_block);
48f609cf782ab5e90ddf045dc4b0da8cebf99be0d1Eric Anholt
498ab5842a6d992956ee365c0e0232c6e6b907863eEric Anholtvoid
508ab5842a6d992956ee365c0e0232c6e6b907863eEric Anholtlink_assign_uniform_block_offsets(struct gl_shader *shader);
518ab5842a6d992956ee365c0e0232c6e6b907863eEric Anholt
52747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick/**
53747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick * Class for processing all of the leaf fields of an uniform
54747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick *
55747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick * Leaves are, roughly speaking, the parts of the uniform that the application
56747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick * could query with \c glGetUniformLocation (or that could be returned by
57747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick * \c glGetActiveUniforms).
58747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick *
59747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick * Classes my derive from this class to implement specific functionality.
60747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick * This class only provides the mechanism to iterate over the leaves.  Derived
61747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick * classes must implement \c ::visit_field and may override \c ::process.
62747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick */
63747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanickclass uniform_field_visitor {
64747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanickpublic:
65747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick   /**
66747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick    * Begin processing a uniform
67747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick    *
68747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick    * Classes that overload this function should call \c ::process from the
69747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick    * base class to start the recursive processing of the uniform.
70747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick    *
71747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick    * \param var  The uniform variable that is to be processed
72747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick    *
73747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick    * Calls \c ::visit_field for each leaf of the uniform.
74747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick    */
75747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick   void process(ir_variable *var);
76747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick
77747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanickprotected:
78747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick   /**
79747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick    * Method invoked for each leaf of the uniform
80747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick    *
81747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick    * \param type  Type of the field.
82747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick    * \param name  Fully qualified name of the field.
83747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick    */
84747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick   virtual void visit_field(const glsl_type *type, const char *name) = 0;
85747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick
86747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanickprivate:
87747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick   /**
88747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick    * \param name_length  Length of the current name \b not including the
89747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick    *                     terminating \c NUL character.
90747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick    */
918292b7419d0405e94a5ea270ba710d20f0eb071fKenneth Graunke   void recursion(const glsl_type *t, char **name, size_t name_length);
92747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick};
93747e59c7590bd11a4964c6ca12c5ff0dbb6282f2Ian Romanick
948fe8a814b0c746f0f655a67f8755f9dee858d230Ian Romanick#endif /* GLSL_LINKER_H */
95