Mesa (master): i965: Make emit_urb_writes() reserve space for GS header information.

Kenneth Graunke kwg at kemper.freedesktop.org
Wed Oct 21 22:02:37 UTC 2015


Module: Mesa
Branch: master
Commit: ac0a33666bdab6e4d9abca6ae6ee19cb03919dcc
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ac0a33666bdab6e4d9abca6ae6ee19cb03919dcc

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Tue May  5 20:19:04 2015 -0700

i965: Make emit_urb_writes() reserve space for GS header information.

Geometry shaders have additional header data at the beginning of their
output URB entries.  Shaders that use EndPrimitive() or multiple streams
have a control data header; shaders with a dynamic vertex count have an
additional vec4 slot to hold the 32-bit vertex count (and 96 bits of
padding).

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Kristian Høgsberg <krh at bitplanet.net>

---

 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 4610ea1..1b6a199 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -868,6 +868,7 @@ void
 fs_visitor::emit_urb_writes()
 {
    int slot, urb_offset, length;
+   int starting_urb_offset = 0;
    const struct brw_vue_prog_data *vue_prog_data =
       (const struct brw_vue_prog_data *) this->prog_data;
    const struct brw_vs_prog_key *vs_key =
@@ -900,8 +901,21 @@ fs_visitor::emit_urb_writes()
       return;
    }
 
+   if (stage == MESA_SHADER_GEOMETRY) {
+      const struct brw_gs_prog_data *gs_prog_data =
+         (const struct brw_gs_prog_data *) prog_data;
+
+      /* We need to increment the Global Offset to skip over the control data
+       * header and the extra "Vertex Count" field (1 HWord) at the beginning
+       * of the VUE.  We're counting in OWords, so the units are doubled.
+       */
+      starting_urb_offset = 2 * gs_prog_data->control_data_header_size_hwords;
+      if (gs_prog_data->static_vertex_count == -1)
+         starting_urb_offset += 2;
+   }
+
    length = 0;
-   urb_offset = 0;
+   urb_offset = starting_urb_offset;
    flush = false;
    for (slot = 0; slot < vue_map->num_slots; slot++) {
       int varying = vue_map->slot_to_varying[slot];
@@ -1008,7 +1022,7 @@ fs_visitor::emit_urb_writes()
          inst->eot = last && stage == MESA_SHADER_VERTEX;
          inst->mlen = length + 1;
          inst->offset = urb_offset;
-         urb_offset = slot + 1;
+         urb_offset = starting_urb_offset + slot + 1;
          length = 0;
          flush = false;
       }




More information about the mesa-commit mailing list