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
)
255 /* Examine all of the uniforms in all of the shaders and cross validate
258 glsl_symbol_table uniforms
;
259 for (unsigned i
= 0; i
< prog
->_NumLinkedShaders
; i
++) {
260 foreach_list(node
, &prog
->_LinkedShaders
[i
]->ir
) {
261 ir_variable
*const var
= ((ir_instruction
*) node
)->as_variable();
263 if ((var
== NULL
) || (var
->mode
!= ir_var_uniform
))
266 /* If a uniform with this name has already been seen, verify that the
267 * new instance has the same type. In addition, if the uniforms have
268 * initializers, the values of the initializers must be the same.
270 ir_variable
*const existing
= uniforms
.get_variable(var
->name
);
271 if (existing
!= NULL
) {
272 if (var
->type
!= existing
->type
) {
273 linker_error_printf(prog
, "uniform `%s' declared as type "
274 "`%s' and type `%s'\n",
275 var
->name
, var
->type
->name
,
276 existing
->type
->name
);
280 if (var
->constant_value
!= NULL
) {
281 if (existing
->constant_value
!= NULL
) {
282 if (!var
->constant_value
->has_value(existing
->constant_value
)) {
283 linker_error_printf(prog
, "initializers for uniform "
284 "`%s' have differing values\n",
289 /* If the first-seen instance of a particular uniform did not
290 * have an initializer but a later instance does, copy the
291 * initializer to the version stored in the symbol table.
293 existing
->constant_value
=
294 (ir_constant
*)var
->constant_value
->clone(NULL
);
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_program
*prog
, unsigned max_attribute_index
)
536 /* Mark invalid attribute locations as being used.
538 unsigned used_locations
= (max_attribute_index
>= 32)
539 ? ~0 : ~((1 << max_attribute_index
) - 1);
541 glsl_shader
*const sh
= prog
->_LinkedShaders
[0];
542 assert(sh
->Type
== GL_VERTEX_SHADER
);
544 /* Operate in a total of four passes.
546 * 1. Invalidate the location assignments for all vertex shader inputs.
548 * 2. Assign locations for inputs that have user-defined (via
549 * glBindVertexAttribLocation) locatoins.
551 * 3. Sort the attributes without assigned locations by number of slots
552 * required in decreasing order. Fragmentation caused by attribute
553 * locations assigned by the application may prevent large attributes
554 * from having enough contiguous space.
556 * 4. Assign locations to any inputs without assigned locations.
559 invalidate_variable_locations(sh
, ir_var_in
, VERT_ATTRIB_GENERIC0
);
561 if (prog
->Attributes
!= NULL
) {
562 for (unsigned i
= 0; i
< prog
->Attributes
->NumParameters
; i
++) {
563 ir_variable
*const var
=
564 sh
->symbols
->get_variable(prog
->Attributes
->Parameters
[i
].Name
);
566 /* Note: attributes that occupy multiple slots, such as arrays or
567 * matrices, may appear in the attrib array multiple times.
569 if ((var
== NULL
) || (var
->location
!= -1))
572 /* From page 61 of the OpenGL 4.0 spec:
574 * "LinkProgram will fail if the attribute bindings assigned by
575 * BindAttribLocation do not leave not enough space to assign a
576 * location for an active matrix attribute or an active attribute
577 * array, both of which require multiple contiguous generic
580 * Previous versions of the spec contain similar language but omit the
581 * bit about attribute arrays.
583 * Page 61 of the OpenGL 4.0 spec also says:
585 * "It is possible for an application to bind more than one
586 * attribute name to the same location. This is referred to as
587 * aliasing. This will only work if only one of the aliased
588 * attributes is active in the executable program, or if no path
589 * through the shader consumes more than one attribute of a set
590 * of attributes aliased to the same location. A link error can
591 * occur if the linker determines that every path through the
592 * shader consumes multiple aliased attributes, but
593 * implementations are not required to generate an error in this
596 * These two paragraphs are either somewhat contradictory, or I don't
597 * fully understand one or both of them.
599 /* FINISHME: The code as currently written does not support attribute
600 * FINISHME: location aliasing (see comment above).
602 const int attr
= prog
->Attributes
->Parameters
[i
].StateIndexes
[0];
603 const unsigned slots
= count_attribute_slots(var
->type
);
605 /* Mask representing the contiguous slots that will be used by this
608 const unsigned use_mask
= (1 << slots
) - 1;
610 /* Generate a link error if the set of bits requested for this
611 * attribute overlaps any previously allocated bits.
613 if ((~(use_mask
<< attr
) & used_locations
) != used_locations
) {
614 linker_error_printf(prog
,
615 "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 linker_error_printf(prog
,
680 "insufficient contiguous attribute locations "
681 "available for vertex shader input `%s'",
682 to_assign
[i
].var
->name
);
686 to_assign
[i
].var
->location
= VERT_ATTRIB_GENERIC0
+ location
;
687 used_locations
|= (use_mask
<< location
);
695 assign_varying_locations(glsl_shader
*producer
, glsl_shader
*consumer
)
697 /* FINISHME: Set dynamically when geometry shader support is added. */
698 unsigned output_index
= VERT_RESULT_VAR0
;
699 unsigned input_index
= FRAG_ATTRIB_VAR0
;
701 /* Operate in a total of three passes.
703 * 1. Assign locations for any matching inputs and outputs.
705 * 2. Mark output variables in the producer that do not have locations as
706 * not being outputs. This lets the optimizer eliminate them.
708 * 3. Mark input variables in the consumer that do not have locations as
709 * not being inputs. This lets the optimizer eliminate them.
712 invalidate_variable_locations(producer
, ir_var_out
, VERT_RESULT_VAR0
);
713 invalidate_variable_locations(consumer
, ir_var_in
, FRAG_ATTRIB_VAR0
);
715 foreach_list(node
, &producer
->ir
) {
716 ir_variable
*const output_var
= ((ir_instruction
*) node
)->as_variable();
718 if ((output_var
== NULL
) || (output_var
->mode
!= ir_var_out
)
719 || (output_var
->location
!= -1))
722 ir_variable
*const input_var
=
723 consumer
->symbols
->get_variable(output_var
->name
);
725 if ((input_var
== NULL
) || (input_var
->mode
!= ir_var_in
))
728 assert(input_var
->location
== -1);
730 /* FINISHME: Location assignment will need some changes when arrays,
731 * FINISHME: matrices, and structures are allowed as shader inputs /
734 output_var
->location
= output_index
;
735 input_var
->location
= input_index
;
741 foreach_list(node
, &producer
->ir
) {
742 ir_variable
*const var
= ((ir_instruction
*) node
)->as_variable();
744 if ((var
== NULL
) || (var
->mode
!= ir_var_out
))
747 /* An 'out' variable is only really a shader output if its value is read
748 * by the following stage.
750 var
->shader_out
= (var
->location
!= -1);
753 foreach_list(node
, &consumer
->ir
) {
754 ir_variable
*const var
= ((ir_instruction
*) node
)->as_variable();
756 if ((var
== NULL
) || (var
->mode
!= ir_var_in
))
759 /* An 'in' variable is only really a shader input if its value is written
760 * by the previous stage.
762 var
->shader_in
= (var
->location
!= -1);
768 link_shaders(struct glsl_program
*prog
)
770 prog
->LinkStatus
= false;
771 prog
->Validated
= false;
774 if (prog
->InfoLog
!= NULL
)
775 talloc_free(prog
->InfoLog
);
777 prog
->InfoLog
= talloc_strdup(NULL
, "");
779 /* Separate the shaders into groups based on their type.
781 struct glsl_shader
**vert_shader_list
;
782 unsigned num_vert_shaders
= 0;
783 struct glsl_shader
**frag_shader_list
;
784 unsigned num_frag_shaders
= 0;
786 vert_shader_list
= (struct glsl_shader
**)
787 calloc(2 * prog
->NumShaders
, sizeof(struct glsl_shader
*));
788 frag_shader_list
= &vert_shader_list
[prog
->NumShaders
];
790 for (unsigned i
= 0; i
< prog
->NumShaders
; i
++) {
791 switch (prog
->Shaders
[i
]->Type
) {
792 case GL_VERTEX_SHADER
:
793 vert_shader_list
[num_vert_shaders
] = prog
->Shaders
[i
];
796 case GL_FRAGMENT_SHADER
:
797 frag_shader_list
[num_frag_shaders
] = prog
->Shaders
[i
];
800 case GL_GEOMETRY_SHADER
:
801 /* FINISHME: Support geometry shaders. */
802 assert(prog
->Shaders
[i
]->Type
!= GL_GEOMETRY_SHADER
);
807 /* FINISHME: Implement intra-stage linking. */
808 assert(num_vert_shaders
<= 1);
809 assert(num_frag_shaders
<= 1);
811 /* Verify that each of the per-target executables is valid.
813 if (!validate_vertex_shader_executable(prog
, vert_shader_list
[0])
814 || !validate_fragment_shader_executable(prog
, frag_shader_list
[0]))
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 /* Here begins the inter-stage linking phase. Some initial validation is
833 * performed, then locations are assigned for uniforms, attributes, and
836 if (cross_validate_uniforms(prog
)) {
837 /* Validate the inputs of each stage with the output of the preceeding
840 for (unsigned i
= 1; i
< prog
->_NumLinkedShaders
; i
++) {
841 if (!cross_validate_outputs_to_inputs(prog
,
842 prog
->_LinkedShaders
[i
- 1],
843 prog
->_LinkedShaders
[i
]))
847 prog
->LinkStatus
= true;
850 /* FINISHME: Perform whole-program optimization here. */
852 assign_uniform_locations(prog
);
854 if (prog
->_LinkedShaders
[0]->Type
== GL_VERTEX_SHADER
)
855 /* FINISHME: The value of the max_attribute_index parameter is
856 * FINISHME: implementation dependent based on the value of
857 * FINISHME: GL_MAX_VERTEX_ATTRIBS. GL_MAX_VERTEX_ATTRIBS must be
858 * FINISHME: at least 16, so hardcode 16 for now.
860 if (!assign_attribute_locations(prog
, 16))
863 for (unsigned i
= 1; i
< prog
->_NumLinkedShaders
; i
++)
864 assign_varying_locations(prog
->_LinkedShaders
[i
- 1],
865 prog
->_LinkedShaders
[i
]);
867 /* FINISHME: Assign fragment shader output locations. */
870 free(vert_shader_list
);