linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]);
if (linked_prog) {
- bool ok = true;
+ static const GLenum targets[] = {
+ GL_VERTEX_PROGRAM_ARB,
+ GL_FRAGMENT_PROGRAM_ARB,
+ GL_GEOMETRY_PROGRAM_NV
+ };
- switch (prog->_LinkedShaders[i]->Type) {
- case GL_VERTEX_SHADER:
+ if (i == MESA_SHADER_VERTEX) {
((struct gl_vertex_program *)linked_prog)->UsesClipDistance
= prog->Vert.UsesClipDistance;
- _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
- linked_prog);
- ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
- linked_prog);
- break;
- case GL_FRAGMENT_SHADER:
- _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
- linked_prog);
- ok = ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB,
- linked_prog);
- break;
- case GL_GEOMETRY_SHADER:
- _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
- linked_prog);
- ok = ctx->Driver.ProgramStringNotify(ctx, GL_GEOMETRY_PROGRAM_NV,
- linked_prog);
- break;
- }
- if (!ok) {
+ }
+
+ _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
+ linked_prog);
+ if (!ctx->Driver.ProgramStringNotify(ctx, targets[i], linked_prog)) {
return GL_FALSE;
}
}
linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]);
if (linked_prog) {
- bool ok = true;
-
- switch (prog->_LinkedShaders[i]->Type) {
- case GL_VERTEX_SHADER:
- _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
- linked_prog);
- ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
- linked_prog);
- if (!ok) {
- _mesa_reference_vertprog(ctx, &prog->VertexProgram, NULL);
- }
- break;
- case GL_FRAGMENT_SHADER:
- _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
- linked_prog);
- ok = ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB,
- linked_prog);
- if (!ok) {
- _mesa_reference_fragprog(ctx, &prog->FragmentProgram, NULL);
- }
- break;
- case GL_GEOMETRY_SHADER:
- _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
- linked_prog);
- ok = ctx->Driver.ProgramStringNotify(ctx, GL_GEOMETRY_PROGRAM_NV,
- linked_prog);
- if (!ok) {
- _mesa_reference_geomprog(ctx, &prog->GeometryProgram, NULL);
- }
- break;
- }
- if (!ok) {
- _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program, NULL);
+ static const GLenum targets[] = {
+ GL_VERTEX_PROGRAM_ARB,
+ GL_FRAGMENT_PROGRAM_ARB,
+ GL_GEOMETRY_PROGRAM_NV
+ };
+
+ _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
+ linked_prog);
+ if (!ctx->Driver.ProgramStringNotify(ctx, targets[i], linked_prog)) {
+ _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
+ NULL);
_mesa_reference_program(ctx, &linked_prog, NULL);
return GL_FALSE;
}