+ /* Compute VCM cache size. We set up our program to take up less than
+ * half of the VPM, so that any set of bin and render programs won't
+ * run out of space. We need space for at least one input segment,
+ * and then allocate the rest to output segments (one for the current
+ * program, the rest to VCM). The valid range of the VCM cache size
+ * field is 1-4 16-vertex batches, but GFXH-1744 limits us to 2-4
+ * batches.
+ */
+ assert(c->devinfo->vpm_size);
+ int sector_size = 16 * sizeof(uint32_t) * 8;
+ int vpm_size_in_sectors = c->devinfo->vpm_size / sector_size;
+ int half_vpm = vpm_size_in_sectors / 2;
+ int vpm_output_batches = half_vpm - prog_data->vpm_input_size;
+ assert(vpm_output_batches >= 2);
+ prog_data->vcm_cache_size = CLAMP(vpm_output_batches - 1, 2, 4);
+