draw, st/mesa: generate TGSI for ffvp/ARB_vp if draw lacks LLVM
[mesa.git] / src / mesa / state_tracker / st_program.c
index 81d6e16fefa4dd93e0c33fb52ab062949d97cad2..84fd8e320af81c4a7ea84e4eee0fec21bc92c940 100644 (file)
@@ -450,7 +450,24 @@ st_translate_vertex_program(struct st_context *st,
       if (stp->Base.Parameters->NumParameters)
          stp->affected_states |= ST_NEW_VS_CONSTANTS;
 
-      /* No samplers are allowed in ARB_vp. */
+      /* Translate to NIR if preferred. */
+      if (st->pipe->screen->get_shader_param(st->pipe->screen,
+                                             PIPE_SHADER_VERTEX,
+                                             PIPE_SHADER_CAP_PREFERRED_IR)) {
+         assert(!stp->glsl_to_tgsi);
+
+         if (stp->Base.nir)
+            ralloc_free(stp->Base.nir);
+
+         stp->state.type = PIPE_SHADER_IR_NIR;
+         stp->Base.nir = st_translate_prog_to_nir(st, &stp->Base,
+                                                  MESA_SHADER_VERTEX);
+         /* For st_draw_feedback, we need to generate TGSI too if draw doesn't
+          * use LLVM.
+          */
+         if (draw_has_llvm())
+            return true;
+      }
    }
 
    /* Get semantic names and indices. */
@@ -541,27 +558,6 @@ st_translate_vertex_program(struct st_context *st,
       st_store_ir_in_disk_cache(st, &stp->Base, false);
    }
 
-   /* Translate to NIR.
-    *
-    * This must be done after the translation to TGSI is done, because
-    * we'll pass the NIR shader to the driver and the TGSI version to
-    * the draw module for the select/feedback/rasterpos code.
-    */
-   if (st->pipe->screen->get_shader_param(st->pipe->screen,
-                                          PIPE_SHADER_VERTEX,
-                                          PIPE_SHADER_CAP_PREFERRED_IR)) {
-      assert(!stp->glsl_to_tgsi);
-
-      nir_shader *nir =
-         st_translate_prog_to_nir(st, &stp->Base, MESA_SHADER_VERTEX);
-
-      if (stp->Base.nir)
-         ralloc_free(stp->Base.nir);
-      stp->state.type = PIPE_SHADER_IR_NIR;
-      stp->Base.nir = nir;
-      return true;
-   }
-
    return stp->state.tokens != NULL;
 }
 
@@ -586,7 +582,8 @@ st_create_vp_variant(struct st_context *st,
 
    state.stream_output = stvp->state.stream_output;
 
-   if (stvp->state.type == PIPE_SHADER_IR_NIR) {
+   if (stvp->state.type == PIPE_SHADER_IR_NIR &&
+       (!key->is_draw_shader || draw_has_llvm())) {
       bool finalize = false;
 
       state.type = PIPE_SHADER_IR_NIR;