- 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 &&
+ st_common_variant(stvp->variants)->key.passthrough_edgeflags == st->vertdata_edgeflags &&
+ !st_common_variant(stvp->variants)->key.is_draw_shader) {
+ st->vp_variant = st_common_variant(stvp->variants);
+ } else {
+ struct st_common_variant_key key;
+
+ 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));
+
+ key.lower_depth_clamp =
+ !st->gp && !st->tep &&
+ st->clamp_frag_depth_in_shader &&
+ (st->ctx->Transform.DepthClampNear ||
+ st->ctx->Transform.DepthClampFar);
+
+ if (key.lower_depth_clamp)
+ key.clip_negative_one_to_one =
+ st->ctx->Transform.ClipDepthMode == GL_NEGATIVE_ONE_TO_ONE;
+
+ /* _NEW_POINT */
+ key.lower_point_size = st->lower_point_size &&
+ !st_point_size_per_vertex(st->ctx);
+
+ /* _NEW_TRANSFORM */
+ if (st->lower_ucp && st_user_clip_planes_enabled(st->ctx) &&
+ !st->ctx->GeometryProgram._Current)
+ key.lower_ucp = st->ctx->Transform.ClipPlanesEnabled;
+
+ st->vp_variant = st_get_vp_variant(st, stvp, &key);
+ }