+ if (brw->urb.gs_present && !gs_present)
+ brw_emit_mi_flush(brw);
+ brw->urb.gs_present = gs_present;
+}
+
+static void
+upload_urb(struct brw_context *brw)
+{
+ /* BRW_NEW_VS_PROG_DATA */
+ const struct brw_vue_prog_data *vs_vue_prog_data =
+ brw_vue_prog_data(brw->vs.base.prog_data);
+ const unsigned vs_size = MAX2(vs_vue_prog_data->urb_entry_size, 1);
+
+ /* BRW_NEW_GEOMETRY_PROGRAM, BRW_NEW_GS_PROG_DATA */
+ const bool gs_present =
+ brw->ff_gs.prog_active || brw->programs[MESA_SHADER_GEOMETRY];
+
+ /* Whe using GS to do transform feedback only we use the same VUE layout for
+ * VS outputs and GS outputs (as it's what the SF and Clipper expect), so we
+ * can simply make the GS URB entry size the same as for the VS. This may
+ * technically be too large in cases where we have few vertex attributes and
+ * a lot of varyings, since the VS size is determined by the larger of the
+ * two. For now, it's safe.
+ *
+ * For user-provided GS the assumption above does not hold since the GS
+ * outputs can be different from the VS outputs.
+ */
+ unsigned gs_size = vs_size;
+ if (brw->programs[MESA_SHADER_GEOMETRY]) {
+ const struct brw_vue_prog_data *gs_vue_prog_data =
+ brw_vue_prog_data(brw->gs.base.prog_data);
+ gs_size = gs_vue_prog_data->urb_entry_size;
+ assert(gs_size >= 1);
+ }
+
+ gen6_upload_urb(brw, vs_size, gs_present, gs_size);