2 * Mesa 3-D graphics library
5 * Copyright (C) 2006 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 #if !defined SLANG_LINK_H
28 #include "slang_compile.h"
30 #if defined __cplusplus
37 SLANG_SHADER_FRAGMENT
,
45 * Active uniforms/attribs can be queried by the application to get a
46 * list of uniforms/attribs actually used by shaders (uniforms) or
47 * vertex shader only (attribs).
52 slang_export_data_quant
*quant
;
54 } slang_active_variable
;
58 slang_active_variable
*table
;
60 } slang_active_variables
;
65 * Attrib binding override.
67 * The application can override GL attrib binding by specifying its
68 * preferred index assignment for a given attrib name. Those overrides
69 * are taken into account while linking the program.
76 } slang_attrib_override
;
80 slang_attrib_override
*table
;
82 } slang_attrib_overrides
;
87 _slang_attrib_overrides_add (slang_attrib_overrides
*, GLuint
, const GLchar
*);
93 * Each slang_uniform_binding holds an array of addresses to actual
94 * memory locations in those shader types that use that
95 * uniform. Uniform bindings are held in an array and accessed by
96 * array index which is seen to the application as a uniform location.
98 * When the application writes to a particular uniform, it specifies
99 * its location. This location is treated as an array index to
100 * slang_uniform_bindings::table and tested against
101 * slang_uniform_bindings::count limit. The result is a pointer to
102 * slang_uniform_binding. The type of data being written to uniform
103 * is tested against slang_uniform_binding::quant. If the types are
104 * compatible, the array slang_uniform_binding::address is iterated
105 * for each shader type and if the address is valid (i.e. the uniform
106 * is used by this shader type), the new uniform value is written at
112 slang_export_data_quant
*quant
;
114 GLuint address
[SLANG_SHADER_MAX
];
115 } slang_uniform_binding
;
119 slang_uniform_binding
*table
;
121 } slang_uniform_bindings
;
128 * There is a fixed number of vertex attrib vectors (attrib
129 * slots). The slang_attrib_slot::addr maps vertex attrib index to the
130 * actual memory location of the attrib in vertex shader. One vertex
131 * attrib can span over many attrib slots (this is the case for
132 * matrices). The slang_attrib_binding::first_slot_index holds the
133 * first slot index that the attrib is bound to.
138 slang_export_data_quant
*quant
;
140 GLuint first_slot_index
;
141 } slang_attrib_binding
;
145 GLuint addr
; /**< memory location */
146 GLuint fill
; /**< 1..4, number of components used */
151 slang_attrib_binding bindings
[MAX_VERTEX_ATTRIBS
];
152 GLuint binding_count
;
153 slang_attrib_slot slots
[MAX_VERTEX_ATTRIBS
];
154 } slang_attrib_bindings
;
162 * There is a fixed number of varying floats (varying slots). The
163 * slang_varying_slot::vert_addr maps varying float index to the
164 * actual memory location of the output variable in vertex shader.
165 * The slang_varying_slot::frag_addr maps varying float index to the
166 * actual memory location of the input variable in fragment shader.
173 } slang_varying_slot
;
177 slang_export_data_quant
*quant
;
179 GLuint first_slot_index
;
180 } slang_varying_binding
;
184 slang_varying_binding bindings
[MAX_VARYING_FLOATS
];
185 GLuint binding_count
;
186 slang_varying_slot slots
[MAX_VARYING_FLOATS
];
188 } slang_varying_bindings
;
195 * A slang_texture_usage struct holds indirect information about
196 * texture image unit usage. The slang_texture_usages::table is
197 * derived from active uniform table by extracting only uniforms that
200 * To collect current texture usage one must iterate the
201 * slang_texture_usages::table and read uniform at address
202 * slang_texture_usage::frag_address to get texture unit index. This
203 * index, coupled with texture access type (target) taken from
204 * slang_texture_usage::quant forms texture usage for that texture
210 slang_export_data_quant
*quant
;
212 } slang_texture_usage
;
216 slang_texture_usage
*table
;
218 } slang_texture_usages
;
223 _slang_texture_usages_ctr (slang_texture_usages
*);
226 _slang_texture_usages_dtr (slang_texture_usages
*);
230 SLANG_COMMON_FIXED_MODELVIEWMATRIX
,
231 SLANG_COMMON_FIXED_PROJECTIONMATRIX
,
232 SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIX
,
233 SLANG_COMMON_FIXED_TEXTUREMATRIX
,
234 SLANG_COMMON_FIXED_NORMALMATRIX
,
235 SLANG_COMMON_FIXED_MODELVIEWMATRIXINVERSE
,
236 SLANG_COMMON_FIXED_PROJECTIONMATRIXINVERSE
,
237 SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXINVERSE
,
238 SLANG_COMMON_FIXED_TEXTUREMATRIXINVERSE
,
239 SLANG_COMMON_FIXED_MODELVIEWMATRIXTRANSPOSE
,
240 SLANG_COMMON_FIXED_PROJECTIONMATRIXTRANSPOSE
,
241 SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXTRANSPOSE
,
242 SLANG_COMMON_FIXED_TEXTUREMATRIXTRANSPOSE
,
243 SLANG_COMMON_FIXED_MODELVIEWMATRIXINVERSETRANSPOSE
,
244 SLANG_COMMON_FIXED_PROJECTIONMATRIXINVERSETRANSPOSE
,
245 SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXINVERSETRANSPOSE
,
246 SLANG_COMMON_FIXED_TEXTUREMATRIXINVERSETRANSPOSE
,
247 SLANG_COMMON_FIXED_NORMALSCALE
,
248 SLANG_COMMON_FIXED_DEPTHRANGE
,
249 SLANG_COMMON_FIXED_CLIPPLANE
,
250 SLANG_COMMON_FIXED_POINT
,
251 SLANG_COMMON_FIXED_FRONTMATERIAL
,
252 SLANG_COMMON_FIXED_BACKMATERIAL
,
253 SLANG_COMMON_FIXED_LIGHTSOURCE
,
254 SLANG_COMMON_FIXED_LIGHTMODEL
,
255 SLANG_COMMON_FIXED_FRONTLIGHTMODELPRODUCT
,
256 SLANG_COMMON_FIXED_BACKLIGHTMODELPRODUCT
,
257 SLANG_COMMON_FIXED_FRONTLIGHTPRODUCT
,
258 SLANG_COMMON_FIXED_BACKLIGHTPRODUCT
,
259 SLANG_COMMON_FIXED_TEXTUREENVCOLOR
,
260 SLANG_COMMON_FIXED_EYEPLANES
,
261 SLANG_COMMON_FIXED_EYEPLANET
,
262 SLANG_COMMON_FIXED_EYEPLANER
,
263 SLANG_COMMON_FIXED_EYEPLANEQ
,
264 SLANG_COMMON_FIXED_OBJECTPLANES
,
265 SLANG_COMMON_FIXED_OBJECTPLANET
,
266 SLANG_COMMON_FIXED_OBJECTPLANER
,
267 SLANG_COMMON_FIXED_OBJECTPLANEQ
,
268 SLANG_COMMON_FIXED_FOG
,
269 SLANG_COMMON_FIXED_MAX
274 SLANG_VERTEX_FIXED_POSITION
,
275 SLANG_VERTEX_FIXED_POINTSIZE
,
276 SLANG_VERTEX_FIXED_CLIPVERTEX
,
277 SLANG_VERTEX_FIXED_COLOR
,
278 SLANG_VERTEX_FIXED_SECONDARYCOLOR
,
279 SLANG_VERTEX_FIXED_NORMAL
,
280 SLANG_VERTEX_FIXED_VERTEX
,
281 SLANG_VERTEX_FIXED_MULTITEXCOORD0
,
282 SLANG_VERTEX_FIXED_MULTITEXCOORD1
,
283 SLANG_VERTEX_FIXED_MULTITEXCOORD2
,
284 SLANG_VERTEX_FIXED_MULTITEXCOORD3
,
285 SLANG_VERTEX_FIXED_MULTITEXCOORD4
,
286 SLANG_VERTEX_FIXED_MULTITEXCOORD5
,
287 SLANG_VERTEX_FIXED_MULTITEXCOORD6
,
288 SLANG_VERTEX_FIXED_MULTITEXCOORD7
,
289 SLANG_VERTEX_FIXED_FOGCOORD
,
290 SLANG_VERTEX_FIXED_FRONTCOLOR
,
291 SLANG_VERTEX_FIXED_BACKCOLOR
,
292 SLANG_VERTEX_FIXED_FRONTSECONDARYCOLOR
,
293 SLANG_VERTEX_FIXED_BACKSECONDARYCOLOR
,
294 SLANG_VERTEX_FIXED_TEXCOORD
,
295 SLANG_VERTEX_FIXED_FOGFRAGCOORD
,
296 SLANG_VERTEX_FIXED_MAX
301 SLANG_FRAGMENT_FIXED_FRAGCOORD
,
302 SLANG_FRAGMENT_FIXED_FRONTFACING
,
303 SLANG_FRAGMENT_FIXED_FRAGCOLOR
,
304 SLANG_FRAGMENT_FIXED_FRAGDATA
,
305 SLANG_FRAGMENT_FIXED_FRAGDEPTH
,
306 SLANG_FRAGMENT_FIXED_COLOR
,
307 SLANG_FRAGMENT_FIXED_SECONDARYCOLOR
,
308 SLANG_FRAGMENT_FIXED_TEXCOORD
,
309 SLANG_FRAGMENT_FIXED_FOGFRAGCOORD
,
310 SLANG_FRAGMENT_FIXED_MAX
315 SLANG_COMMON_CODE_MAIN
,
316 SLANG_COMMON_CODE_MAX
321 slang_active_variables active_uniforms
;
322 slang_active_variables active_attribs
;
323 slang_attrib_overrides attrib_overrides
;
324 slang_uniform_bindings uniforms
;
325 slang_attrib_bindings attribs
;
326 slang_varying_bindings varyings
;
327 slang_texture_usages texture_usage
;
328 GLuint common_fixed_entries
[SLANG_SHADER_MAX
][SLANG_COMMON_FIXED_MAX
];
329 GLuint vertex_fixed_entries
[SLANG_VERTEX_FIXED_MAX
];
330 GLuint fragment_fixed_entries
[SLANG_FRAGMENT_FIXED_MAX
];
331 GLuint code
[SLANG_SHADER_MAX
][SLANG_COMMON_CODE_MAX
];
332 slang_machine
*machines
[SLANG_SHADER_MAX
];
333 slang_assembly_file
*assemblies
[SLANG_SHADER_MAX
];
337 _slang_program_ctr (slang_program
*);
340 _slang_program_dtr (slang_program
*);
343 _slang_program_rst (slang_program
*);
346 _slang_link (slang_program
*, slang_code_object
**, GLuint
);