mesa: increase max texture image units and GLSL samplers to 16
[mesa.git] / src / mesa / shader / slang / slang_link.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 7.2
4 *
5 * Copyright (C) 2008 Brian Paul All Rights Reserved.
6 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
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.
23 */
24
25 /**
26 * \file slang_link.c
27 * GLSL linker
28 * \author Brian Paul
29 */
30
31 #include "main/imports.h"
32 #include "main/context.h"
33 #include "main/hash.h"
34 #include "main/macros.h"
35 #include "shader/program.h"
36 #include "shader/prog_instruction.h"
37 #include "shader/prog_parameter.h"
38 #include "shader/prog_print.h"
39 #include "shader/prog_statevars.h"
40 #include "shader/prog_uniform.h"
41 #include "shader/shader_api.h"
42 #include "slang_link.h"
43
44
45 /** cast wrapper */
46 static struct gl_vertex_program *
47 vertex_program(struct gl_program *prog)
48 {
49 assert(prog->Target == GL_VERTEX_PROGRAM_ARB);
50 return (struct gl_vertex_program *) prog;
51 }
52
53
54 /** cast wrapper */
55 static struct gl_fragment_program *
56 fragment_program(struct gl_program *prog)
57 {
58 assert(prog->Target == GL_FRAGMENT_PROGRAM_ARB);
59 return (struct gl_fragment_program *) prog;
60 }
61
62
63 /**
64 * Record a linking error.
65 */
66 static void
67 link_error(struct gl_shader_program *shProg, const char *msg)
68 {
69 if (shProg->InfoLog) {
70 _mesa_free(shProg->InfoLog);
71 }
72 shProg->InfoLog = _mesa_strdup(msg);
73 shProg->LinkStatus = GL_FALSE;
74 }
75
76
77
78 /**
79 * Check if the given bit is either set or clear in both bitfields.
80 */
81 static GLboolean
82 bits_agree(GLbitfield flags1, GLbitfield flags2, GLbitfield bit)
83 {
84 return (flags1 & bit) == (flags2 & bit);
85 }
86
87
88 /**
89 * Linking varying vars involves rearranging varying vars so that the
90 * vertex program's output varyings matches the order of the fragment
91 * program's input varyings.
92 * We'll then rewrite instructions to replace PROGRAM_VARYING with either
93 * PROGRAM_INPUT or PROGRAM_OUTPUT depending on whether it's a vertex or
94 * fragment shader.
95 * This is also where we set program Input/OutputFlags to indicate
96 * which inputs are centroid-sampled, invariant, etc.
97 */
98 static GLboolean
99 link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog)
100 {
101 GLuint *map, i, firstVarying, newFile;
102 GLbitfield *inOutFlags;
103
104 map = (GLuint *) malloc(prog->Varying->NumParameters * sizeof(GLuint));
105 if (!map)
106 return GL_FALSE;
107
108 /* Varying variables are treated like other vertex program outputs
109 * (and like other fragment program inputs). The position of the
110 * first varying differs for vertex/fragment programs...
111 * Also, replace File=PROGRAM_VARYING with File=PROGRAM_INPUT/OUTPUT.
112 */
113 if (prog->Target == GL_VERTEX_PROGRAM_ARB) {
114 firstVarying = VERT_RESULT_VAR0;
115 newFile = PROGRAM_OUTPUT;
116 inOutFlags = prog->OutputFlags;
117 }
118 else {
119 assert(prog->Target == GL_FRAGMENT_PROGRAM_ARB);
120 firstVarying = FRAG_ATTRIB_VAR0;
121 newFile = PROGRAM_INPUT;
122 inOutFlags = prog->InputFlags;
123 }
124
125 for (i = 0; i < prog->Varying->NumParameters; i++) {
126 /* see if this varying is in the linked varying list */
127 const struct gl_program_parameter *var = prog->Varying->Parameters + i;
128 GLint j = _mesa_lookup_parameter_index(shProg->Varying, -1, var->Name);
129 if (j >= 0) {
130 /* varying is already in list, do some error checking */
131 const struct gl_program_parameter *v =
132 &shProg->Varying->Parameters[j];
133 if (var->Size != v->Size) {
134 link_error(shProg, "mismatched varying variable types");
135 return GL_FALSE;
136 }
137 if (!bits_agree(var->Flags, v->Flags, PROG_PARAM_BIT_CENTROID)) {
138 char msg[100];
139 snprintf(msg, sizeof(msg),
140 "centroid modifier mismatch for '%s'", var->Name);
141 link_error(shProg, msg);
142 return GL_FALSE;
143 }
144 if (!bits_agree(var->Flags, v->Flags, PROG_PARAM_BIT_INVARIANT)) {
145 char msg[100];
146 snprintf(msg, sizeof(msg),
147 "invariant modifier mismatch for '%s'", var->Name);
148 link_error(shProg, msg);
149 return GL_FALSE;
150 }
151 }
152 else {
153 /* not already in linked list */
154 j = _mesa_add_varying(shProg->Varying, var->Name, var->Size,
155 var->Flags);
156 }
157
158 /* Map varying[i] to varying[j].
159 * Plus, set prog->Input/OutputFlags[] as described above.
160 * Note: the loop here takes care of arrays or large (sz>4) vars.
161 */
162 {
163 GLint sz = var->Size;
164 while (sz > 0) {
165 inOutFlags[firstVarying + j] = var->Flags;
166 /*printf("Link varying from %d to %d\n", i, j);*/
167 map[i++] = j++;
168 sz -= 4;
169 }
170 i--; /* go back one */
171 }
172 }
173
174
175 /* OK, now scan the program/shader instructions looking for varying vars,
176 * replacing the old index with the new index.
177 */
178 for (i = 0; i < prog->NumInstructions; i++) {
179 struct prog_instruction *inst = prog->Instructions + i;
180 GLuint j;
181
182 if (inst->DstReg.File == PROGRAM_VARYING) {
183 inst->DstReg.File = newFile;
184 inst->DstReg.Index = map[ inst->DstReg.Index ] + firstVarying;
185 }
186
187 for (j = 0; j < 3; j++) {
188 if (inst->SrcReg[j].File == PROGRAM_VARYING) {
189 inst->SrcReg[j].File = newFile;
190 inst->SrcReg[j].Index = map[ inst->SrcReg[j].Index ] + firstVarying;
191 }
192 }
193 }
194
195 free(map);
196
197 /* these will get recomputed before linking is completed */
198 prog->InputsRead = 0x0;
199 prog->OutputsWritten = 0x0;
200
201 return GL_TRUE;
202 }
203
204
205 /**
206 * Build the shProg->Uniforms list.
207 * This is basically a list/index of all uniforms found in either/both of
208 * the vertex and fragment shaders.
209 */
210 static GLboolean
211 link_uniform_vars(GLcontext *ctx,
212 struct gl_shader_program *shProg,
213 struct gl_program *prog,
214 GLuint *numSamplers)
215 {
216 GLuint samplerMap[MAX_SAMPLERS];
217 GLuint i;
218
219 for (i = 0; i < prog->Parameters->NumParameters; i++) {
220 const struct gl_program_parameter *p = prog->Parameters->Parameters + i;
221
222 /*
223 * XXX FIX NEEDED HERE
224 * We should also be adding a uniform if p->Type == PROGRAM_STATE_VAR.
225 * For example, modelview matrix, light pos, etc.
226 * Also, we need to update the state-var name-generator code to
227 * generate GLSL-style names, like "gl_LightSource[0].position".
228 * Furthermore, we'll need to fix the state-var's size/datatype info.
229 */
230
231 if ((p->Type == PROGRAM_UNIFORM && p->Used) ||
232 p->Type == PROGRAM_SAMPLER) {
233 struct gl_uniform *uniform =
234 _mesa_append_uniform(shProg->Uniforms, p->Name, prog->Target, i);
235 if (uniform)
236 uniform->Initialized = p->Initialized;
237 }
238
239 if (p->Type == PROGRAM_SAMPLER) {
240 /* Allocate a new sampler index */
241 GLuint sampNum = *numSamplers;
242 GLuint oldSampNum = (GLuint) prog->Parameters->ParameterValues[i][0];
243 if (oldSampNum >= ctx->Const.MaxTextureImageUnits) {
244 char s[100];
245 sprintf(s, "Too many texture samplers (%u, max is %u)",
246 oldSampNum + 1, ctx->Const.MaxTextureImageUnits);
247 link_error(shProg, s);
248 return GL_FALSE;
249 }
250 samplerMap[oldSampNum] = sampNum;
251 (*numSamplers)++;
252 }
253 }
254
255
256 /* OK, now scan the program/shader instructions looking for sampler vars,
257 * replacing the old index with the new index.
258 */
259 prog->SamplersUsed = 0x0;
260 for (i = 0; i < prog->NumInstructions; i++) {
261 struct prog_instruction *inst = prog->Instructions + i;
262 if (_mesa_is_tex_instruction(inst->Opcode)) {
263 /*
264 printf("====== remap sampler from %d to %d\n",
265 inst->Sampler, map[ inst->Sampler ]);
266 */
267 /* here, texUnit is really samplerUnit */
268 assert(inst->TexSrcUnit < MAX_SAMPLERS);
269 inst->TexSrcUnit = samplerMap[inst->TexSrcUnit];
270 prog->SamplerTargets[inst->TexSrcUnit] = inst->TexSrcTarget;
271 prog->SamplersUsed |= (1 << inst->TexSrcUnit);
272 }
273 }
274
275 return GL_TRUE;
276 }
277
278
279 /**
280 * Resolve binding of generic vertex attributes.
281 * For example, if the vertex shader declared "attribute vec4 foobar" we'll
282 * allocate a generic vertex attribute for "foobar" and plug that value into
283 * the vertex program instructions.
284 * But if the user called glBindAttributeLocation(), those bindings will
285 * have priority.
286 */
287 static GLboolean
288 _slang_resolve_attributes(struct gl_shader_program *shProg,
289 const struct gl_program *origProg,
290 struct gl_program *linkedProg)
291 {
292 GLint attribMap[MAX_VERTEX_ATTRIBS];
293 GLuint i, j;
294 GLbitfield usedAttributes;
295
296 assert(origProg != linkedProg);
297 assert(origProg->Target == GL_VERTEX_PROGRAM_ARB);
298 assert(linkedProg->Target == GL_VERTEX_PROGRAM_ARB);
299
300 if (!shProg->Attributes)
301 shProg->Attributes = _mesa_new_parameter_list();
302
303 if (linkedProg->Attributes) {
304 _mesa_free_parameter_list(linkedProg->Attributes);
305 }
306 linkedProg->Attributes = _mesa_new_parameter_list();
307
308
309 /* Build a bitmask indicating which attribute indexes have been
310 * explicitly bound by the user with glBindAttributeLocation().
311 */
312 usedAttributes = 0x0;
313 for (i = 0; i < shProg->Attributes->NumParameters; i++) {
314 GLint attr = shProg->Attributes->Parameters[i].StateIndexes[0];
315 usedAttributes |= (1 << attr);
316 }
317
318 /* initialize the generic attribute map entries to -1 */
319 for (i = 0; i < MAX_VERTEX_ATTRIBS; i++) {
320 attribMap[i] = -1;
321 }
322
323 /*
324 * Scan program for generic attribute references
325 */
326 for (i = 0; i < linkedProg->NumInstructions; i++) {
327 struct prog_instruction *inst = linkedProg->Instructions + i;
328 for (j = 0; j < 3; j++) {
329 if (inst->SrcReg[j].File == PROGRAM_INPUT &&
330 inst->SrcReg[j].Index >= VERT_ATTRIB_GENERIC0) {
331 /*
332 * OK, we've found a generic vertex attribute reference.
333 */
334 const GLint k = inst->SrcReg[j].Index - VERT_ATTRIB_GENERIC0;
335
336 GLint attr = attribMap[k];
337
338 if (attr < 0) {
339 /* Need to figure out attribute mapping now.
340 */
341 const char *name = origProg->Attributes->Parameters[k].Name;
342 const GLint size = origProg->Attributes->Parameters[k].Size;
343 const GLenum type =origProg->Attributes->Parameters[k].DataType;
344 GLint index;
345
346 /* See if there's a user-defined attribute binding for
347 * this name.
348 */
349 index = _mesa_lookup_parameter_index(shProg->Attributes,
350 -1, name);
351 if (index >= 0) {
352 /* Found a user-defined binding */
353 attr = shProg->Attributes->Parameters[index].StateIndexes[0];
354 }
355 else {
356 /* No user-defined binding, choose our own attribute number.
357 * Start at 1 since generic attribute 0 always aliases
358 * glVertex/position.
359 */
360 for (attr = 1; attr < MAX_VERTEX_ATTRIBS; attr++) {
361 if (((1 << attr) & usedAttributes) == 0)
362 break;
363 }
364 if (attr == MAX_VERTEX_ATTRIBS) {
365 link_error(shProg, "Too many vertex attributes");
366 return GL_FALSE;
367 }
368
369 /* mark this attribute as used */
370 usedAttributes |= (1 << attr);
371 }
372
373 attribMap[k] = attr;
374
375 /* Save the final name->attrib binding so it can be queried
376 * with glGetAttributeLocation().
377 */
378 _mesa_add_attribute(linkedProg->Attributes, name,
379 size, type, attr);
380 }
381
382 assert(attr >= 0);
383
384 /* update the instruction's src reg */
385 inst->SrcReg[j].Index = VERT_ATTRIB_GENERIC0 + attr;
386 }
387 }
388 }
389
390 return GL_TRUE;
391 }
392
393
394 /**
395 * Scan program instructions to update the program's NumTemporaries field.
396 * Note: this implemenation relies on the code generator allocating
397 * temps in increasing order (0, 1, 2, ... ).
398 */
399 static void
400 _slang_count_temporaries(struct gl_program *prog)
401 {
402 GLuint i, j;
403 GLint maxIndex = -1;
404
405 for (i = 0; i < prog->NumInstructions; i++) {
406 const struct prog_instruction *inst = prog->Instructions + i;
407 const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode);
408 for (j = 0; j < numSrc; j++) {
409 if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) {
410 if (maxIndex < inst->SrcReg[j].Index)
411 maxIndex = inst->SrcReg[j].Index;
412 }
413 if (inst->DstReg.File == PROGRAM_TEMPORARY) {
414 if (maxIndex < (GLint) inst->DstReg.Index)
415 maxIndex = inst->DstReg.Index;
416 }
417 }
418 }
419
420 prog->NumTemporaries = (GLuint) (maxIndex + 1);
421 }
422
423
424 /**
425 * Scan program instructions to update the program's InputsRead and
426 * OutputsWritten fields.
427 */
428 static void
429 _slang_update_inputs_outputs(struct gl_program *prog)
430 {
431 GLuint i, j;
432 GLuint maxAddrReg = 0;
433
434 prog->InputsRead = 0x0;
435 prog->OutputsWritten = 0x0;
436
437 for (i = 0; i < prog->NumInstructions; i++) {
438 const struct prog_instruction *inst = prog->Instructions + i;
439 const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode);
440 for (j = 0; j < numSrc; j++) {
441 if (inst->SrcReg[j].File == PROGRAM_INPUT) {
442 prog->InputsRead |= 1 << inst->SrcReg[j].Index;
443 if (prog->Target == GL_FRAGMENT_PROGRAM_ARB &&
444 inst->SrcReg[j].Index == FRAG_ATTRIB_FOGC) {
445 /* The fragment shader FOGC input is used for fog,
446 * front-facing and sprite/point coord.
447 */
448 struct gl_fragment_program *fp = fragment_program(prog);
449 const GLint swz = GET_SWZ(inst->SrcReg[j].Swizzle, 0);
450 if (swz == SWIZZLE_X)
451 fp->UsesFogFragCoord = GL_TRUE;
452 else if (swz == SWIZZLE_Y)
453 fp->UsesFrontFacing = GL_TRUE;
454 else if (swz == SWIZZLE_Z || swz == SWIZZLE_W)
455 fp->UsesPointCoord = GL_TRUE;
456 }
457 }
458 else if (inst->SrcReg[j].File == PROGRAM_ADDRESS) {
459 maxAddrReg = MAX2(maxAddrReg, (GLuint) (inst->SrcReg[j].Index + 1));
460 }
461 }
462 if (inst->DstReg.File == PROGRAM_OUTPUT) {
463 prog->OutputsWritten |= 1 << inst->DstReg.Index;
464 }
465 else if (inst->DstReg.File == PROGRAM_ADDRESS) {
466 maxAddrReg = MAX2(maxAddrReg, inst->DstReg.Index + 1);
467 }
468 }
469
470 prog->NumAddressRegs = maxAddrReg;
471 }
472
473
474 /**
475 * Shader linker. Currently:
476 *
477 * 1. The last attached vertex shader and fragment shader are linked.
478 * 2. Varying vars in the two shaders are combined so their locations
479 * agree between the vertex and fragment stages. They're treated as
480 * vertex program output attribs and as fragment program input attribs.
481 * 3. The vertex and fragment programs are cloned and modified to update
482 * src/dst register references so they use the new, linked varying
483 * storage locations.
484 */
485 void
486 _slang_link(GLcontext *ctx,
487 GLhandleARB programObj,
488 struct gl_shader_program *shProg)
489 {
490 const struct gl_vertex_program *vertProg;
491 const struct gl_fragment_program *fragProg;
492 GLuint numSamplers = 0;
493 GLuint i;
494
495 _mesa_clear_shader_program_data(ctx, shProg);
496
497 /* check that all programs compiled successfully */
498 for (i = 0; i < shProg->NumShaders; i++) {
499 if (!shProg->Shaders[i]->CompileStatus) {
500 link_error(shProg, "linking with uncompiled shader\n");
501 return;
502 }
503 }
504
505 shProg->Uniforms = _mesa_new_uniform_list();
506 shProg->Varying = _mesa_new_parameter_list();
507
508 /**
509 * Find attached vertex, fragment shaders defining main()
510 */
511 vertProg = NULL;
512 fragProg = NULL;
513 for (i = 0; i < shProg->NumShaders; i++) {
514 struct gl_shader *shader = shProg->Shaders[i];
515 if (shader->Type == GL_VERTEX_SHADER) {
516 if (shader->Main)
517 vertProg = vertex_program(shader->Program);
518 }
519 else if (shader->Type == GL_FRAGMENT_SHADER) {
520 if (shader->Main)
521 fragProg = fragment_program(shader->Program);
522 }
523 else {
524 _mesa_problem(ctx, "unexpected shader target in slang_link()");
525 }
526 }
527
528 #if FEATURE_es2_glsl
529 /* must have both a vertex and fragment program for ES2 */
530 if (!vertProg) {
531 link_error(shProg, "missing vertex shader\n");
532 return;
533 }
534 if (!fragProg) {
535 link_error(shProg, "missing fragment shader\n");
536 return;
537 }
538 #endif
539
540 /*
541 * Make copies of the vertex/fragment programs now since we'll be
542 * changing src/dst registers after merging the uniforms and varying vars.
543 */
544 _mesa_reference_vertprog(ctx, &shProg->VertexProgram, NULL);
545 if (vertProg) {
546 struct gl_vertex_program *linked_vprog =
547 vertex_program(_mesa_clone_program(ctx, &vertProg->Base));
548 shProg->VertexProgram = linked_vprog; /* refcount OK */
549 ASSERT(shProg->VertexProgram->Base.RefCount == 1);
550 }
551
552 _mesa_reference_fragprog(ctx, &shProg->FragmentProgram, NULL);
553 if (fragProg) {
554 struct gl_fragment_program *linked_fprog =
555 fragment_program(_mesa_clone_program(ctx, &fragProg->Base));
556 shProg->FragmentProgram = linked_fprog; /* refcount OK */
557 ASSERT(shProg->FragmentProgram->Base.RefCount == 1);
558 }
559
560 /* link varying vars */
561 if (shProg->VertexProgram) {
562 if (!link_varying_vars(shProg, &shProg->VertexProgram->Base))
563 return;
564 }
565 if (shProg->FragmentProgram) {
566 if (!link_varying_vars(shProg, &shProg->FragmentProgram->Base))
567 return;
568 }
569
570 /* link uniform vars */
571 if (shProg->VertexProgram) {
572 if (!link_uniform_vars(ctx, shProg, &shProg->VertexProgram->Base,
573 &numSamplers)) {
574 return;
575 }
576 }
577 if (shProg->FragmentProgram) {
578 if (!link_uniform_vars(ctx, shProg, &shProg->FragmentProgram->Base,
579 &numSamplers)) {
580 return;
581 }
582 }
583
584 /*_mesa_print_uniforms(shProg->Uniforms);*/
585
586 if (shProg->VertexProgram) {
587 if (!_slang_resolve_attributes(shProg, &vertProg->Base,
588 &shProg->VertexProgram->Base)) {
589 return;
590 }
591 }
592
593 if (shProg->VertexProgram) {
594 _slang_update_inputs_outputs(&shProg->VertexProgram->Base);
595 _slang_count_temporaries(&shProg->VertexProgram->Base);
596 if (!(shProg->VertexProgram->Base.OutputsWritten & (1 << VERT_RESULT_HPOS))) {
597 /* the vertex program did not compute a vertex position */
598 link_error(shProg,
599 "gl_Position was not written by vertex shader\n");
600 return;
601 }
602 }
603 if (shProg->FragmentProgram) {
604 _slang_count_temporaries(&shProg->FragmentProgram->Base);
605 _slang_update_inputs_outputs(&shProg->FragmentProgram->Base);
606 }
607
608 /* Check that all the varying vars needed by the fragment shader are
609 * actually produced by the vertex shader.
610 */
611 if (shProg->FragmentProgram) {
612 const GLbitfield varyingRead
613 = shProg->FragmentProgram->Base.InputsRead >> FRAG_ATTRIB_VAR0;
614 const GLbitfield varyingWritten = shProg->VertexProgram ?
615 shProg->VertexProgram->Base.OutputsWritten >> VERT_RESULT_VAR0 : 0x0;
616 if ((varyingRead & varyingWritten) != varyingRead) {
617 link_error(shProg,
618 "Fragment program using varying vars not written by vertex shader\n");
619 return;
620 }
621 }
622
623
624 if (fragProg && shProg->FragmentProgram) {
625 /* Compute initial program's TexturesUsed info */
626 _mesa_update_shader_textures_used(&shProg->FragmentProgram->Base);
627
628 /* notify driver that a new fragment program has been compiled/linked */
629 ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB,
630 &shProg->FragmentProgram->Base);
631 if (MESA_VERBOSE & VERBOSE_GLSL_DUMP) {
632 printf("Mesa original fragment program:\n");
633 _mesa_print_program(&fragProg->Base);
634 _mesa_print_program_parameters(ctx, &fragProg->Base);
635
636 printf("Mesa post-link fragment program:\n");
637 _mesa_print_program(&shProg->FragmentProgram->Base);
638 _mesa_print_program_parameters(ctx, &shProg->FragmentProgram->Base);
639 }
640 }
641
642 if (vertProg && shProg->VertexProgram) {
643 /* Compute initial program's TexturesUsed info */
644 _mesa_update_shader_textures_used(&shProg->VertexProgram->Base);
645
646 /* notify driver that a new vertex program has been compiled/linked */
647 ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
648 &shProg->VertexProgram->Base);
649 if (MESA_VERBOSE & VERBOSE_GLSL_DUMP) {
650 printf("Mesa original vertex program:\n");
651 _mesa_print_program(&vertProg->Base);
652 _mesa_print_program_parameters(ctx, &vertProg->Base);
653
654 printf("Mesa post-link vertex program:\n");
655 _mesa_print_program(&shProg->VertexProgram->Base);
656 _mesa_print_program_parameters(ctx, &shProg->VertexProgram->Base);
657 }
658 }
659
660 if (MESA_VERBOSE & VERBOSE_GLSL_DUMP) {
661 printf("Varying vars:\n");
662 _mesa_print_parameter_list(shProg->Varying);
663 }
664
665 shProg->LinkStatus = (shProg->VertexProgram || shProg->FragmentProgram);
666 }
667