- brw_compute_vue_map(brw->intelScreen->devinfo,
- &c.prog_data.base.vue_map, outputs_written,
- prog ? prog->SeparateShader : false);
-
- /* Compute the output vertex size.
- *
- * From the Ivy Bridge PRM, Vol2 Part1 7.2.1.1 STATE_GS - Output Vertex
- * Size (p168):
- *
- * [0,62] indicating [1,63] 16B units
- *
- * Specifies the size of each vertex stored in the GS output entry
- * (following any Control Header data) as a number of 128-bit units
- * (minus one).
- *
- * Programming Restrictions: The vertex size must be programmed as a
- * multiple of 32B units with the following exception: Rendering is
- * disabled (as per SOL stage state) and the vertex size output by the
- * GS thread is 16B.
- *
- * If rendering is enabled (as per SOL state) the vertex size must be
- * programmed as a multiple of 32B units. In other words, the only time
- * software can program a vertex size with an odd number of 16B units
- * is when rendering is disabled.
- *
- * Note: B=bytes in the above text.
- *
- * It doesn't seem worth the extra trouble to optimize the case where the
- * vertex size is 16B (especially since this would require special-casing
- * the GEN assembly that writes to the URB). So we just set the vertex
- * size to a multiple of 32B (2 vec4's) in all cases.
- *
- * The maximum output vertex size is 62*16 = 992 bytes (31 hwords). We
- * budget that as follows:
- *
- * 512 bytes for varyings (a varying component is 4 bytes and
- * gl_MaxGeometryOutputComponents = 128)
- * 16 bytes overhead for VARYING_SLOT_PSIZ (each varying slot is 16
- * bytes)
- * 16 bytes overhead for gl_Position (we allocate it a slot in the VUE
- * even if it's not used)
- * 32 bytes overhead for gl_ClipDistance (we allocate it 2 VUE slots
- * whenever clip planes are enabled, even if the shader doesn't
- * write to gl_ClipDistance)
- * 16 bytes overhead since the VUE size must be a multiple of 32 bytes
- * (see below)--this causes up to 1 VUE slot to be wasted
- * 400 bytes available for varying packing overhead
- *
- * Worst-case varying packing overhead is 3/4 of a varying slot (12 bytes)
- * per interpolation type, so this is plenty.
- *
- */
- unsigned output_vertex_size_bytes = c.prog_data.base.vue_map.num_slots * 16;
- assert(brw->gen == 6 ||
- output_vertex_size_bytes <= GEN7_MAX_GS_OUTPUT_VERTEX_SIZE_BYTES);
- c.prog_data.output_vertex_size_hwords =
- ALIGN(output_vertex_size_bytes, 32) / 32;
-
- /* Compute URB entry size. The maximum allowed URB entry size is 32k.
- * That divides up as follows:
- *
- * 64 bytes for the control data header (cut indices or StreamID bits)
- * 4096 bytes for varyings (a varying component is 4 bytes and
- * gl_MaxGeometryTotalOutputComponents = 1024)
- * 4096 bytes overhead for VARYING_SLOT_PSIZ (each varying slot is 16
- * bytes/vertex and gl_MaxGeometryOutputVertices is 256)
- * 4096 bytes overhead for gl_Position (we allocate it a slot in the VUE
- * even if it's not used)
- * 8192 bytes overhead for gl_ClipDistance (we allocate it 2 VUE slots
- * whenever clip planes are enabled, even if the shader doesn't
- * write to gl_ClipDistance)
- * 4096 bytes overhead since the VUE size must be a multiple of 32
- * bytes (see above)--this causes up to 1 VUE slot to be wasted
- * 8128 bytes available for varying packing overhead
- *
- * Worst-case varying packing overhead is 3/4 of a varying slot per
- * interpolation type, which works out to 3072 bytes, so this would allow
- * us to accommodate 2 interpolation types without any danger of running
- * out of URB space.
- *
- * In practice, the risk of running out of URB space is very small, since
- * the above figures are all worst-case, and most of them scale with the
- * number of output vertices. So we'll just calculate the amount of space
- * we need, and if it's too large, fail to compile.
- *
- * The above is for gen7+ where we have a single URB entry that will hold
- * all the output. In gen6, we will have to allocate URB entries for every
- * vertex we emit, so our URB entries only need to be large enough to hold
- * a single vertex. Also, gen6 does not have a control data header.
- */
- unsigned output_size_bytes;
- if (brw->gen >= 7) {
- output_size_bytes =
- c.prog_data.output_vertex_size_hwords * 32 * gp->program.VerticesOut;
- output_size_bytes += 32 * c.prog_data.control_data_header_size_hwords;
- } else {
- output_size_bytes = c.prog_data.output_vertex_size_hwords * 32;
- }
-
- /* Broadwell stores "Vertex Count" as a full 8 DWord (32 byte) URB output,
- * which comes before the control header.
- */
- if (brw->gen >= 8)
- output_size_bytes += 32;
-
- assert(output_size_bytes >= 1);
- int max_output_size_bytes = GEN7_MAX_GS_URB_ENTRY_SIZE_BYTES;
- if (brw->gen == 6)
- max_output_size_bytes = GEN6_MAX_GS_URB_ENTRY_SIZE_BYTES;
- if (output_size_bytes > max_output_size_bytes)
- return false;
-