stfp = st_fragment_program(st->ctx->FragmentProgram._Current);
assert(stfp->Base.Target == GL_FRAGMENT_PROGRAM_ARB);
- memset(&key, 0, sizeof(key));
- key.st = st->has_shareable_shaders ? NULL : st;
-
- /* _NEW_FRAG_CLAMP */
- key.clamp_color = st->clamp_frag_color_in_shader &&
- st->ctx->Color._ClampFragmentColor;
-
- /* _NEW_MULTISAMPLE | _NEW_BUFFERS */
- key.persample_shading =
- st->force_persample_in_shader &&
- _mesa_is_multisample_enabled(st->ctx) &&
- st->ctx->Multisample.SampleShading &&
- st->ctx->Multisample.MinSampleShadingValue *
- _mesa_geometric_samples(st->ctx->DrawBuffer) > 1;
-
- if (stfp->ati_fs) {
- key.fog = st->ctx->Fog._PackedEnabledMode;
-
- for (unsigned u = 0; u < MAX_NUM_FRAGMENT_REGISTERS_ATI; u++) {
- key.texture_targets[u] = get_texture_target(st->ctx, u);
+ void *shader;
+
+ if (st->shader_has_one_variant[MESA_SHADER_FRAGMENT] &&
+ !stfp->ati_fs && /* ATI_fragment_shader always has multiple variants */
+ !stfp->Base.ExternalSamplersUsed && /* external samplers need variants */
+ stfp->variants) {
+ shader = stfp->variants->driver_shader;
+ } else {
+ memset(&key, 0, sizeof(key));
+ key.st = st->has_shareable_shaders ? NULL : st;
+
+ /* _NEW_FRAG_CLAMP */
+ key.clamp_color = st->clamp_frag_color_in_shader &&
+ st->ctx->Color._ClampFragmentColor;
+
+ /* _NEW_MULTISAMPLE | _NEW_BUFFERS */
+ key.persample_shading =
+ st->force_persample_in_shader &&
+ _mesa_is_multisample_enabled(st->ctx) &&
+ st->ctx->Multisample.SampleShading &&
+ st->ctx->Multisample.MinSampleShadingValue *
+ _mesa_geometric_samples(st->ctx->DrawBuffer) > 1;
+
+ if (stfp->ati_fs) {
+ key.fog = st->ctx->Fog._PackedEnabledMode;
+
+ for (unsigned u = 0; u < MAX_NUM_FRAGMENT_REGISTERS_ATI; u++) {
+ key.texture_targets[u] = get_texture_target(st->ctx, u);
+ }
}
- }
- key.external = st_get_external_sampler_key(st, &stfp->Base);
+ key.external = st_get_external_sampler_key(st, &stfp->Base);
- void *shader = st_get_fp_variant(st, stfp, &key)->driver_shader;
+ shader = st_get_fp_variant(st, stfp, &key)->driver_shader;
+ }
st_reference_fragprog(st, &st->fp, stfp);
stvp = st_vertex_program(st->ctx->VertexProgram._Current);
assert(stvp->Base.Target == GL_VERTEX_PROGRAM_ARB);
- memset(&key, 0, sizeof key);
- key.st = st->has_shareable_shaders ? NULL : st;
-
- /* When this is true, we will add an extra input to the vertex
- * shader translation (for edgeflags), an extra output with
- * edgeflag semantics, and extend the vertex shader to pass through
- * the input to the output. We'll need to use similar logic to set
- * up the extra vertex_element input for edgeflags.
- */
- key.passthrough_edgeflags = st->vertdata_edgeflags;
-
- key.clamp_color = st->clamp_vert_color_in_shader &&
- st->ctx->Light._ClampVertexColor &&
- (stvp->Base.info.outputs_written &
- (VARYING_SLOT_COL0 |
- VARYING_SLOT_COL1 |
- VARYING_SLOT_BFC0 |
- VARYING_SLOT_BFC1));
-
- st->vp_variant = st_get_vp_variant(st, stvp, &key);
+ if (st->shader_has_one_variant[MESA_SHADER_VERTEX] &&
+ stvp->variants &&
+ stvp->variants->key.passthrough_edgeflags == st->vertdata_edgeflags) {
+ st->vp_variant = stvp->variants;
+ } else {
+ memset(&key, 0, sizeof key);
+ key.st = st->has_shareable_shaders ? NULL : st;
+
+ /* When this is true, we will add an extra input to the vertex
+ * shader translation (for edgeflags), an extra output with
+ * edgeflag semantics, and extend the vertex shader to pass through
+ * the input to the output. We'll need to use similar logic to set
+ * up the extra vertex_element input for edgeflags.
+ */
+ key.passthrough_edgeflags = st->vertdata_edgeflags;
+
+ key.clamp_color = st->clamp_vert_color_in_shader &&
+ st->ctx->Light._ClampVertexColor &&
+ (stvp->Base.info.outputs_written &
+ (VARYING_SLOT_COL0 |
+ VARYING_SLOT_COL1 |
+ VARYING_SLOT_BFC0 |
+ VARYING_SLOT_BFC1));
+
+ st->vp_variant = st_get_vp_variant(st, stvp, &key);
+ }
st_reference_vertprog(st, &st->vp, stvp);
stgp = st_common_program(st->ctx->GeometryProgram._Current);
assert(stgp->Base.Target == GL_GEOMETRY_PROGRAM_NV);
- void *shader = st_get_basic_variant(st, PIPE_SHADER_GEOMETRY, &stgp->tgsi,
- &stgp->variants)->driver_shader;
+ void *shader;
+
+ if (st->shader_has_one_variant[MESA_SHADER_GEOMETRY] && stgp->variants) {
+ shader = stgp->variants->driver_shader;
+ } else {
+ shader = st_get_basic_variant(st, PIPE_SHADER_GEOMETRY, &stgp->tgsi,
+ &stgp->variants)->driver_shader;
+ }
st_reference_prog(st, &st->gp, stgp);
sttcp = st_common_program(st->ctx->TessCtrlProgram._Current);
assert(sttcp->Base.Target == GL_TESS_CONTROL_PROGRAM_NV);
- void *shader = st_get_basic_variant(st, PIPE_SHADER_TESS_CTRL, &sttcp->tgsi,
- &sttcp->variants)->driver_shader;
+ void *shader;
+
+ if (st->shader_has_one_variant[MESA_SHADER_TESS_CTRL] && sttcp->variants) {
+ shader = sttcp->variants->driver_shader;
+ } else {
+ shader = st_get_basic_variant(st, PIPE_SHADER_TESS_CTRL, &sttcp->tgsi,
+ &sttcp->variants)->driver_shader;
+ }
st_reference_prog(st, &st->tcp, sttcp);
sttep = st_common_program(st->ctx->TessEvalProgram._Current);
assert(sttep->Base.Target == GL_TESS_EVALUATION_PROGRAM_NV);
- void *shader = st_get_basic_variant(st, PIPE_SHADER_TESS_EVAL, &sttep->tgsi,
- &sttep->variants)->driver_shader;
+ void *shader;
+
+ if (st->shader_has_one_variant[MESA_SHADER_TESS_EVAL] && sttep->variants) {
+ shader = sttep->variants->driver_shader;
+ } else {
+ shader = st_get_basic_variant(st, PIPE_SHADER_TESS_EVAL, &sttep->tgsi,
+ &sttep->variants)->driver_shader;
+ }
st_reference_prog(st, &st->tep, sttep);
stcp = st_compute_program(st->ctx->ComputeProgram._Current);
assert(stcp->Base.Target == GL_COMPUTE_PROGRAM_NV);
- void *shader = st_get_cp_variant(st, &stcp->tgsi,
- &stcp->variants)->driver_shader;
+ void *shader;
+
+ if (st->shader_has_one_variant[MESA_SHADER_COMPUTE] && stcp->variants) {
+ shader = stcp->variants->driver_shader;
+ } else {
+ shader = st_get_cp_variant(st, &stcp->tgsi,
+ &stcp->variants)->driver_shader;
+ }
st_reference_compprog(st, &st->cp, stcp);