-static void
-use_program(struct gl_context *ctx, gl_shader_stage stage,
- struct gl_program *new_prog, struct gl_pipeline_object *shTarget)
-{
- struct gl_program **target;
-
- target = &shTarget->CurrentProgram[stage];
- if (new_prog) {
- _mesa_program_init_subroutine_defaults(ctx, new_prog);
- }
-
- if (*target != new_prog) {
- /* Program is current, flush it */
- if (shTarget == ctx->_Shader) {
- FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
- }
-
- /* If the shader is also bound as the current rendering shader, unbind
- * it from that binding point as well. This ensures that the correct
- * semantics of glDeleteProgram are maintained.
- */
- switch (stage) {
- case MESA_SHADER_VERTEX:
- case MESA_SHADER_TESS_CTRL:
- case MESA_SHADER_TESS_EVAL:
- case MESA_SHADER_GEOMETRY:
- case MESA_SHADER_COMPUTE:
- /* Empty for now. */
- break;
- case MESA_SHADER_FRAGMENT:
- if (*target == ctx->_Shader->_CurrentFragmentProgram) {
- _mesa_reference_program(ctx,
- &ctx->_Shader->_CurrentFragmentProgram,
- NULL);
- }
- break;
- }
-
- _mesa_reference_program(ctx, target, new_prog);
- return;
- }
-}
-
-