From: Kenneth Graunke Date: Tue, 29 Nov 2016 00:59:45 +0000 (-0800) Subject: i965: Fix number of slots in SSO mode when there are no user varyings. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2bae2fa09446ef3168c82e492223b66a05a85b21;p=mesa.git i965: Fix number of slots in SSO mode when there are no user varyings. We want vue_map->num_slots to be one more than the final slot. When assigning fixed slots, built-in slots, and non-SSO user varyings, we do slot++. This leaves "slot" as one past the most recently assigned slot. But for SSO user varyings, we computed slot based on the varying location value...and left it at that slot value. To work around this inconsistency, I made num_slots be "slot + 1" if separate and "slot" otherwise. The problem is...if there are no user varyings in SSO mode...then we would have done slot++ when assigning built-ins, so it would be off by one. This resulted in loops from 0 to vue_map->num_slots hitting a bonus BRW_VARYING_SLOT_PAD at the end. This used to break the SIMD8 VS/TES backends, but I fixed that in commit 480d6c1653713dcae617ac523b2ca5deee01c845. It's probably safe at this point, but we should fix it anyway. To fix this, do slot++ in all cases. For SSO mode, we overwrite slot for every varying, so this increment only matters on the last varying. Because we process varyings in order, this will set slot to 1 more than the highest assigned slot. Signed-off-by: Kenneth Graunke Reviewed-by: Jordan Justen --- diff --git a/src/mesa/drivers/dri/i965/brw_vue_map.c b/src/mesa/drivers/dri/i965/brw_vue_map.c index 982a31f9034..0d8f6c700b6 100644 --- a/src/mesa/drivers/dri/i965/brw_vue_map.c +++ b/src/mesa/drivers/dri/i965/brw_vue_map.c @@ -181,14 +181,12 @@ brw_compute_vue_map(const struct gen_device_info *devinfo, const int varying = ffsll(generics) - 1; if (separate) { slot = first_generic_slot + varying - VARYING_SLOT_VAR0; - assign_vue_slot(vue_map, varying, slot); - } else { - assign_vue_slot(vue_map, varying, slot++); } + assign_vue_slot(vue_map, varying, slot++); generics &= ~BITFIELD64_BIT(varying); } - vue_map->num_slots = separate ? slot + 1 : slot; + vue_map->num_slots = slot; vue_map->num_per_vertex_slots = 0; vue_map->num_per_patch_slots = 0; }