2 * Copyright © 2010 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
26 * GLSL linker implementation
28 * Given a set of shaders that are to be linked to generate a final program,
29 * there are three distinct stages.
31 * In the first stage shaders are partitioned into groups based on the shader
32 * type. All shaders of a particular type (e.g., vertex shaders) are linked
35 * - Undefined references in each shader are resolve to definitions in
37 * - Types and qualifiers of uniforms, outputs, and global variables defined
38 * in multiple shaders with the same name are verified to be the same.
39 * - Initializers for uniforms and global variables defined
40 * in multiple shaders with the same name are verified to be the same.
42 * The result, in the terminology of the GLSL spec, is a set of shader
43 * executables for each processing unit.
45 * After the first stage is complete, a series of semantic checks are performed
46 * on each of the shader executables.
48 * - Each shader executable must define a \c main function.
49 * - Each vertex shader executable must write to \c gl_Position.
50 * - Each fragment shader executable must write to either \c gl_FragData or
53 * In the final stage individual shader executables are linked to create a
54 * complete exectuable.
56 * - Types of uniforms defined in multiple shader stages with the same name
57 * are verified to be the same.
58 * - Initializers for uniforms defined in multiple shader stages with the
59 * same name are verified to be the same.
60 * - Types and qualifiers of outputs defined in one stage are verified to
61 * be the same as the types and qualifiers of inputs defined with the same
62 * name in a later stage.
64 * \author Ian Romanick <ian.d.romanick@intel.com>
74 #include "main/mtypes.h"
75 #include "glsl_symbol_table.h"
76 #include "glsl_parser_extras.h"
78 #include "ir_optimization.h"
80 #include "hash_table.h"
83 * Visitor that determines whether or not a variable is ever written.
85 class find_assignment_visitor
: public ir_hierarchical_visitor
{
87 find_assignment_visitor(const char *name
)
88 : name(name
), found(false)
93 virtual ir_visitor_status
visit_enter(ir_assignment
*ir
)
95 ir_variable
*const var
= ir
->lhs
->variable_referenced();
97 if (strcmp(name
, var
->name
) == 0) {
102 return visit_continue_with_parent
;
105 bool variable_found()
111 const char *name
; /**< Find writes to a variable with this name. */
112 bool found
; /**< Was a write to the variable found? */
117 linker_error_printf(glsl_program
*prog
, const char *fmt
, ...)
121 prog
->InfoLog
= talloc_strdup_append(prog
->InfoLog
, "error: ");
123 prog
->InfoLog
= talloc_vasprintf_append(prog
->InfoLog
, fmt
, ap
);
129 invalidate_variable_locations(glsl_shader
*sh
, enum ir_variable_mode mode
,
132 foreach_list(node
, &sh
->ir
) {
133 ir_variable
*const var
= ((ir_instruction
*) node
)->as_variable();
135 if ((var
== NULL
) || (var
->mode
!= (unsigned) mode
))
138 /* Only assign locations for generic attributes / varyings / etc.
140 if (var
->location
>= generic_base
)
147 * Determine the number of attribute slots required for a particular type
149 * This code is here because it implements the language rules of a specific
150 * GLSL version. Since it's a property of the language and not a property of
151 * types in general, it doesn't really belong in glsl_type.
154 count_attribute_slots(const glsl_type
*t
)
156 /* From page 31 (page 37 of the PDF) of the GLSL 1.50 spec:
158 * "A scalar input counts the same amount against this limit as a vec4,
159 * so applications may want to consider packing groups of four
160 * unrelated float inputs together into a vector to better utilize the
161 * capabilities of the underlying hardware. A matrix input will use up
162 * multiple locations. The number of locations used will equal the
163 * number of columns in the matrix."
165 * The spec does not explicitly say how arrays are counted. However, it
166 * should be safe to assume the total number of slots consumed by an array
167 * is the number of entries in the array multiplied by the number of slots
168 * consumed by a single element of the array.
172 return t
->array_size() * count_attribute_slots(t
->element_type());
175 return t
->matrix_columns
;
182 * Verify that a vertex shader executable meets all semantic requirements
184 * \param shader Vertex shader executable to be verified
187 validate_vertex_shader_executable(struct glsl_program
*prog
,
188 struct glsl_shader
*shader
)
193 if (!shader
->symbols
->get_function("main")) {
194 linker_error_printf(prog
, "vertex shader lacks `main'\n");
198 find_assignment_visitor
find("gl_Position");
199 find
.run(&shader
->ir
);
200 if (!find
.variable_found()) {
201 linker_error_printf(prog
,
202 "vertex shader does not write to `gl_Position'\n");
211 * Verify that a fragment shader executable meets all semantic requirements
213 * \param shader Fragment shader executable to be verified
216 validate_fragment_shader_executable(struct glsl_program
*prog
,
217 struct glsl_shader
*shader
)
222 if (!shader
->symbols
->get_function("main")) {
223 linker_error_printf(prog
, "fragment shader lacks `main'\n");
227 find_assignment_visitor
frag_color("gl_FragColor");
228 find_assignment_visitor
frag_data("gl_FragData");
230 frag_color
.run(&shader
->ir
);
231 frag_data
.run(&shader
->ir
);
233 if (!frag_color
.variable_found() && !frag_data
.variable_found()) {
234 linker_error_printf(prog
, "fragment shader does not write to "
235 "`gl_FragColor' or `gl_FragData'\n");
239 if (frag_color
.variable_found() && frag_data
.variable_found()) {
240 linker_error_printf(prog
, "fragment shader writes to both "
241 "`gl_FragColor' and `gl_FragData'\n");
250 * Perform validation of uniforms used across multiple shader stages
253 cross_validate_uniforms(struct glsl_program
*prog
,
254 struct glsl_shader
**shaders
, unsigned num_shaders
)
256 /* Examine all of the uniforms in all of the shaders and cross validate
259 glsl_symbol_table uniforms
;
260 for (unsigned i
= 0; i
< num_shaders
; i
++) {
261 foreach_list(node
, &shaders
[i
]->ir
) {
262 ir_variable
*const var
= ((ir_instruction
*) node
)->as_variable();
264 if ((var
== NULL
) || (var
->mode
!= ir_var_uniform
))
267 /* If a uniform with this name has already been seen, verify that the
268 * new instance has the same type. In addition, if the uniforms have
269 * initializers, the values of the initializers must be the same.
271 ir_variable
*const existing
= uniforms
.get_variable(var
->name
);
272 if (existing
!= NULL
) {
273 if (var
->type
!= existing
->type
) {
274 linker_error_printf(prog
, "uniform `%s' declared as type "
275 "`%s' and type `%s'\n",
276 var
->name
, var
->type
->name
,
277 existing
->type
->name
);
281 if (var
->constant_value
!= NULL
) {
282 if (existing
->constant_value
!= NULL
) {
283 if (!var
->constant_value
->has_value(existing
->constant_value
)) {
284 linker_error_printf(prog
, "initializers for uniform "
285 "`%s' have differing values\n",
290 /* If the first-seen instance of a particular uniform did not
291 * have an initializer but a later instance does, copy the
292 * initializer to the version stored in the symbol table.
294 existing
->constant_value
= var
->constant_value
->clone();
297 uniforms
.add_variable(var
->name
, var
);
306 * Validate that outputs from one stage match inputs of another
309 cross_validate_outputs_to_inputs(struct glsl_program
*prog
,
310 glsl_shader
*producer
, glsl_shader
*consumer
)
312 glsl_symbol_table parameters
;
313 /* FINISHME: Figure these out dynamically. */
314 const char *const producer_stage
= "vertex";
315 const char *const consumer_stage
= "fragment";
317 /* Find all shader outputs in the "producer" stage.
319 foreach_list(node
, &producer
->ir
) {
320 ir_variable
*const var
= ((ir_instruction
*) node
)->as_variable();
322 /* FINISHME: For geometry shaders, this should also look for inout
323 * FINISHME: variables.
325 if ((var
== NULL
) || (var
->mode
!= ir_var_out
))
328 parameters
.add_variable(var
->name
, var
);
332 /* Find all shader inputs in the "consumer" stage. Any variables that have
333 * matching outputs already in the symbol table must have the same type and
336 foreach_list(node
, &consumer
->ir
) {
337 ir_variable
*const input
= ((ir_instruction
*) node
)->as_variable();
339 /* FINISHME: For geometry shaders, this should also look for inout
340 * FINISHME: variables.
342 if ((input
== NULL
) || (input
->mode
!= ir_var_in
))
345 ir_variable
*const output
= parameters
.get_variable(input
->name
);
346 if (output
!= NULL
) {
347 /* Check that the types match between stages.
349 if (input
->type
!= output
->type
) {
350 linker_error_printf(prog
,
351 "%s shader output `%s' delcared as "
352 "type `%s', but %s shader input declared "
354 producer_stage
, output
->name
,
356 consumer_stage
, input
->type
->name
);
360 /* Check that all of the qualifiers match between stages.
362 if (input
->centroid
!= output
->centroid
) {
363 linker_error_printf(prog
,
364 "%s shader output `%s' %s centroid qualifier, "
365 "but %s shader input %s centroid qualifier\n",
368 (output
->centroid
) ? "has" : "lacks",
370 (input
->centroid
) ? "has" : "lacks");
374 if (input
->invariant
!= output
->invariant
) {
375 linker_error_printf(prog
,
376 "%s shader output `%s' %s invariant qualifier, "
377 "but %s shader input %s invariant qualifier\n",
380 (output
->invariant
) ? "has" : "lacks",
382 (input
->invariant
) ? "has" : "lacks");
386 if (input
->interpolation
!= output
->interpolation
) {
387 linker_error_printf(prog
,
388 "%s shader output `%s' specifies %s "
389 "interpolation qualifier, "
390 "but %s shader input specifies %s "
391 "interpolation qualifier\n",
394 output
->interpolation_string(),
396 input
->interpolation_string());
406 struct uniform_node
{
408 struct gl_uniform
*u
;
413 assign_uniform_locations(struct glsl_program
*prog
)
417 unsigned total_uniforms
= 0;
418 hash_table
*ht
= hash_table_ctor(32, hash_table_string_hash
,
419 hash_table_string_compare
);
421 for (unsigned i
= 0; i
< prog
->_NumLinkedShaders
; i
++) {
422 unsigned next_position
= 0;
424 foreach_list(node
, &prog
->_LinkedShaders
[i
]->ir
) {
425 ir_variable
*const var
= ((ir_instruction
*) node
)->as_variable();
427 if ((var
== NULL
) || (var
->mode
!= ir_var_uniform
))
430 const unsigned vec4_slots
= (var
->component_slots() + 3) / 4;
431 assert(vec4_slots
!= 0);
433 uniform_node
*n
= (uniform_node
*) hash_table_find(ht
, var
->name
);
435 n
= (uniform_node
*) calloc(1, sizeof(struct uniform_node
));
436 n
->u
= (gl_uniform
*) calloc(vec4_slots
, sizeof(struct gl_uniform
));
437 n
->slots
= vec4_slots
;
439 n
->u
[0].Name
= strdup(var
->name
);
440 for (unsigned j
= 1; j
< vec4_slots
; j
++)
441 n
->u
[j
].Name
= n
->u
[0].Name
;
443 hash_table_insert(ht
, n
, n
->u
[0].Name
);
444 uniforms
.push_tail(& n
->link
);
445 total_uniforms
+= vec4_slots
;
448 if (var
->constant_value
!= NULL
)
449 for (unsigned j
= 0; j
< vec4_slots
; j
++)
450 n
->u
[j
].Initialized
= true;
452 var
->location
= next_position
;
454 for (unsigned j
= 0; j
< vec4_slots
; j
++) {
455 switch (prog
->_LinkedShaders
[i
]->Type
) {
456 case GL_VERTEX_SHADER
:
457 n
->u
[j
].VertPos
= next_position
;
459 case GL_FRAGMENT_SHADER
:
460 n
->u
[j
].FragPos
= next_position
;
462 case GL_GEOMETRY_SHADER
:
463 /* FINISHME: Support geometry shaders. */
464 assert(prog
->_LinkedShaders
[i
]->Type
!= GL_GEOMETRY_SHADER
);
473 gl_uniform_list
*ul
= (gl_uniform_list
*)
474 calloc(1, sizeof(gl_uniform_list
));
476 ul
->Size
= total_uniforms
;
477 ul
->NumUniforms
= total_uniforms
;
478 ul
->Uniforms
= (gl_uniform
*) calloc(total_uniforms
, sizeof(gl_uniform
));
482 for (uniform_node
*node
= (uniform_node
*) uniforms
.head
483 ; node
->link
.next
!= NULL
485 next
= (uniform_node
*) node
->link
.next
;
488 memcpy(&ul
->Uniforms
[idx
], node
->u
, sizeof(gl_uniform
) * node
->slots
);
502 * Find a contiguous set of available bits in a bitmask
504 * \param used_mask Bits representing used (1) and unused (0) locations
505 * \param needed_count Number of contiguous bits needed.
508 * Base location of the available bits on success or -1 on failure.
511 find_available_slots(unsigned used_mask
, unsigned needed_count
)
513 unsigned needed_mask
= (1 << needed_count
) - 1;
514 const int max_bit_to_test
= (8 * sizeof(used_mask
)) - needed_count
;
516 /* The comparison to 32 is redundant, but without it GCC emits "warning:
517 * cannot optimize possibly infinite loops" for the loop below.
519 if ((needed_count
== 0) || (max_bit_to_test
< 0) || (max_bit_to_test
> 32))
522 for (int i
= 0; i
<= max_bit_to_test
; i
++) {
523 if ((needed_mask
& ~used_mask
) == needed_mask
)
534 assign_attribute_locations(glsl_shader
*sh
,
535 struct gl_program_parameter_list
*attrib
,
536 unsigned max_attribute_index
)
538 /* Mark invalid attribute locations as being used.
540 unsigned used_locations
= (max_attribute_index
>= 32)
541 ? ~0 : ~((1 << max_attribute_index
) - 1);
543 assert(sh
->Type
== GL_VERTEX_SHADER
);
545 /* Operate in a total of four passes.
547 * 1. Invalidate the location assignments for all vertex shader inputs.
549 * 2. Assign locations for inputs that have user-defined (via
550 * glBindVertexAttribLocation) locatoins.
552 * 3. Sort the attributes without assigned locations by number of slots
553 * required in decreasing order. Fragmentation caused by attribute
554 * locations assigned by the application may prevent large attributes
555 * from having enough contiguous space.
557 * 4. Assign locations to any inputs without assigned locations.
560 invalidate_variable_locations(sh
, ir_var_in
, VERT_ATTRIB_GENERIC0
);
562 if (attrib
!= NULL
) {
563 for (unsigned i
= 0; i
< attrib
->NumParameters
; i
++) {
564 ir_variable
*const var
=
565 sh
->symbols
->get_variable(attrib
->Parameters
[i
].Name
);
567 /* Note: attributes that occupy multiple slots, such as arrays or
568 * matrices, may appear in the attrib array multiple times.
570 if ((var
== NULL
) || (var
->location
!= -1))
573 /* From page 61 of the OpenGL 4.0 spec:
575 * "LinkProgram will fail if the attribute bindings assigned by
576 * BindAttribLocation do not leave not enough space to assign a
577 * location for an active matrix attribute or an active attribute
578 * array, both of which require multiple contiguous generic
581 * Previous versions of the spec contain similar language but omit the
582 * bit about attribute arrays.
584 * Page 61 of the OpenGL 4.0 spec also says:
586 * "It is possible for an application to bind more than one
587 * attribute name to the same location. This is referred to as
588 * aliasing. This will only work if only one of the aliased
589 * attributes is active in the executable program, or if no path
590 * through the shader consumes more than one attribute of a set
591 * of attributes aliased to the same location. A link error can
592 * occur if the linker determines that every path through the
593 * shader consumes multiple aliased attributes, but
594 * implementations are not required to generate an error in this
597 * These two paragraphs are either somewhat contradictory, or I don't
598 * fully understand one or both of them.
600 /* FINISHME: The code as currently written does not support attribute
601 * FINISHME: location aliasing (see comment above).
603 const int attr
= attrib
->Parameters
[i
].StateIndexes
[0];
604 const unsigned slots
= count_attribute_slots(var
->type
);
606 /* Mask representing the contiguous slots that will be used by this
609 const unsigned use_mask
= (1 << slots
) - 1;
611 /* Generate a link error if the set of bits requested for this
612 * attribute overlaps any previously allocated bits.
614 if ((~(use_mask
<< attr
) & used_locations
) != used_locations
) {
615 printf("error: insufficient contiguous attribute locations "
616 "available for vertex shader input `%s'",
621 var
->location
= VERT_ATTRIB_GENERIC0
+ attr
;
622 used_locations
|= (use_mask
<< attr
);
626 /* Temporary storage for the set of attributes that need locations assigned.
632 /* Used below in the call to qsort. */
633 static int compare(const void *a
, const void *b
)
635 const temp_attr
*const l
= (const temp_attr
*) a
;
636 const temp_attr
*const r
= (const temp_attr
*) b
;
638 /* Reversed because we want a descending order sort below. */
639 return r
->slots
- l
->slots
;
643 unsigned num_attr
= 0;
645 foreach_list(node
, &sh
->ir
) {
646 ir_variable
*const var
= ((ir_instruction
*) node
)->as_variable();
648 if ((var
== NULL
) || (var
->mode
!= ir_var_in
))
651 /* The location was explicitly assigned, nothing to do here.
653 if (var
->location
!= -1)
656 to_assign
[num_attr
].slots
= count_attribute_slots(var
->type
);
657 to_assign
[num_attr
].var
= var
;
661 /* If all of the attributes were assigned locations by the application (or
662 * are built-in attributes with fixed locations), return early. This should
663 * be the common case.
668 qsort(to_assign
, num_attr
, sizeof(to_assign
[0]), temp_attr::compare
);
670 for (unsigned i
= 0; i
< num_attr
; i
++) {
671 /* Mask representing the contiguous slots that will be used by this
674 const unsigned use_mask
= (1 << to_assign
[i
].slots
) - 1;
676 int location
= find_available_slots(used_locations
, to_assign
[i
].slots
);
679 printf("error: insufficient contiguous attribute locations "
680 "available for vertex shader input `%s'",
681 to_assign
[i
].var
->name
);
685 to_assign
[i
].var
->location
= VERT_ATTRIB_GENERIC0
+ location
;
686 used_locations
|= (use_mask
<< location
);
694 assign_varying_locations(glsl_shader
*producer
, glsl_shader
*consumer
)
696 /* FINISHME: Set dynamically when geometry shader support is added. */
697 unsigned output_index
= VERT_RESULT_VAR0
;
698 unsigned input_index
= FRAG_ATTRIB_VAR0
;
700 /* Operate in a total of three passes.
702 * 1. Assign locations for any matching inputs and outputs.
704 * 2. Mark output variables in the producer that do not have locations as
705 * not being outputs. This lets the optimizer eliminate them.
707 * 3. Mark input variables in the consumer that do not have locations as
708 * not being inputs. This lets the optimizer eliminate them.
711 invalidate_variable_locations(producer
, ir_var_out
, VERT_RESULT_VAR0
);
712 invalidate_variable_locations(consumer
, ir_var_in
, FRAG_ATTRIB_VAR0
);
714 foreach_list(node
, &producer
->ir
) {
715 ir_variable
*const output_var
= ((ir_instruction
*) node
)->as_variable();
717 if ((output_var
== NULL
) || (output_var
->mode
!= ir_var_out
)
718 || (output_var
->location
!= -1))
721 ir_variable
*const input_var
=
722 consumer
->symbols
->get_variable(output_var
->name
);
724 if ((input_var
== NULL
) || (input_var
->mode
!= ir_var_in
))
727 assert(input_var
->location
== -1);
729 /* FINISHME: Location assignment will need some changes when arrays,
730 * FINISHME: matrices, and structures are allowed as shader inputs /
733 output_var
->location
= output_index
;
734 input_var
->location
= input_index
;
740 foreach_list(node
, &producer
->ir
) {
741 ir_variable
*const var
= ((ir_instruction
*) node
)->as_variable();
743 if ((var
== NULL
) || (var
->mode
!= ir_var_out
))
746 /* An 'out' variable is only really a shader output if its value is read
747 * by the following stage.
749 var
->shader_out
= (var
->location
!= -1);
752 foreach_list(node
, &consumer
->ir
) {
753 ir_variable
*const var
= ((ir_instruction
*) node
)->as_variable();
755 if ((var
== NULL
) || (var
->mode
!= ir_var_in
))
758 /* An 'in' variable is only really a shader input if its value is written
759 * by the previous stage.
761 var
->shader_in
= (var
->location
!= -1);
767 link_shaders(struct glsl_program
*prog
)
769 prog
->LinkStatus
= false;
770 prog
->Validated
= false;
773 if (prog
->InfoLog
!= NULL
)
774 talloc_free(prog
->InfoLog
);
776 prog
->InfoLog
= talloc_strdup(NULL
, "");
778 /* Separate the shaders into groups based on their type.
780 struct glsl_shader
**vert_shader_list
;
781 unsigned num_vert_shaders
= 0;
782 struct glsl_shader
**frag_shader_list
;
783 unsigned num_frag_shaders
= 0;
785 vert_shader_list
= (struct glsl_shader
**)
786 calloc(2 * prog
->NumShaders
, sizeof(struct glsl_shader
*));
787 frag_shader_list
= &vert_shader_list
[prog
->NumShaders
];
789 for (unsigned i
= 0; i
< prog
->NumShaders
; i
++) {
790 switch (prog
->Shaders
[i
]->Type
) {
791 case GL_VERTEX_SHADER
:
792 vert_shader_list
[num_vert_shaders
] = prog
->Shaders
[i
];
795 case GL_FRAGMENT_SHADER
:
796 frag_shader_list
[num_frag_shaders
] = prog
->Shaders
[i
];
799 case GL_GEOMETRY_SHADER
:
800 /* FINISHME: Support geometry shaders. */
801 assert(prog
->Shaders
[i
]->Type
!= GL_GEOMETRY_SHADER
);
806 /* FINISHME: Implement intra-stage linking. */
807 assert(num_vert_shaders
<= 1);
808 assert(num_frag_shaders
<= 1);
810 /* Verify that each of the per-target executables is valid.
812 if (!validate_vertex_shader_executable(prog
, vert_shader_list
[0])
813 || !validate_fragment_shader_executable(prog
, frag_shader_list
[0]))
817 /* FINISHME: Perform inter-stage linking. */
818 prog
->_LinkedShaders
= (struct glsl_shader
**)
819 calloc(2, sizeof(struct glsl_shader
*));
820 prog
->_NumLinkedShaders
= 0;
822 if (num_vert_shaders
> 0) {
823 prog
->_LinkedShaders
[prog
->_NumLinkedShaders
] = vert_shader_list
[0];
824 prog
->_NumLinkedShaders
++;
827 if (num_frag_shaders
> 0) {
828 prog
->_LinkedShaders
[prog
->_NumLinkedShaders
] = frag_shader_list
[0];
829 prog
->_NumLinkedShaders
++;
832 if (cross_validate_uniforms(prog
, prog
->_LinkedShaders
,
833 prog
->_NumLinkedShaders
)) {
834 /* Validate the inputs of each stage with the output of the preceeding
837 for (unsigned i
= 1; i
< prog
->_NumLinkedShaders
; i
++) {
838 if (!cross_validate_outputs_to_inputs(prog
,
839 prog
->_LinkedShaders
[i
- 1],
840 prog
->_LinkedShaders
[i
]))
844 prog
->LinkStatus
= true;
847 /* FINISHME: Perform whole-program optimization here. */
849 assign_uniform_locations(prog
);
851 if (prog
->_LinkedShaders
[0]->Type
== GL_VERTEX_SHADER
)
852 /* FINISHME: The value of the max_attribute_index parameter is
853 * FINISHME: implementation dependent based on the value of
854 * FINISHME: GL_MAX_VERTEX_ATTRIBS. GL_MAX_VERTEX_ATTRIBS must be
855 * FINISHME: at least 16, so hardcode 16 for now.
857 if (!assign_attribute_locations(prog
->_LinkedShaders
[0],
862 for (unsigned i
= 1; i
< prog
->_NumLinkedShaders
; i
++)
863 assign_varying_locations(prog
->_LinkedShaders
[i
- 1],
864 prog
->_LinkedShaders
[i
]);
866 /* FINISHME: Assign fragment shader output locations. */
868 /* FINISHME: Generate code here. */
871 free(vert_shader_list
);