<html><head></head><body><div>Sure, I can do that.</div><div><br></div><div>Iago</div><div><br></div><div>On Tue, 2017-09-26 at 06:32 -0400, Ilia Mirkin wrote:</div><blockquote type="cite"><div dir="auto">Perhaps a debug message would be warranted in such a situation? I suspect it would be difficult to debug, esp if it came up in a regular application.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sep 26, 2017 3:50 AM, "Iago Toral Quiroga" <<a href="mailto:itoral@igalia.com">itoral@igalia.com</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">we can skip these slots when they are not read in the fragment shader<br>
and they are positioned right after a VUE header that we are already<br>
skipping. We also need to ensure that we are passing at least one other<br>
varying, since that is a hardware requirement.<br>
<br>
This helps alleviate a problem introduced with 99df02ca26f61 for<br>
separate shader objects: without separate shader objects we assign<br>
locations sequentially, however, since that commit we have changed the<br>
method for SSO so that the VUE slot assigned depends on the number of<br>
builtin slots plus the location assigned to the varying. This fixed<br>
layout is intended to help SSO programs by avoiding on-the-fly recompiles<br>
when swapping out shaders, however, it also means that if a varying uses<br>
a large location number close to the maximum allowed by the SF/FS units<br>
(31), then the offset introduced by the number of builtin slots can push<br>
the location outside the range and trigger an assertion.<br>
<br>
This problem is affecting at least the following CTS tests for<br>
enhanced layouts:<br>
<br>
KHR-GL45.enhanced_layouts.<wbr>varying_array_components<br>
KHR-GL45.enhanced_layouts.<wbr>varying_array_locations<br>
KHR-GL45.enhanced_layouts.<wbr>varying_components<br>
KHR-GL45.enhanced_layouts.<wbr>varying_locations<br>
<br>
which use SSO and the the location layout qualifier to select such<br>
location numbers explicitly.<br>
<br>
This change helps these tests because for SSO we always have to include<br>
VARYING_SLOT_CLIP_DIST{0,1} even if the fragment shader is very unlikely<br>
to read them, so by doing this we free builtin slots from the fixed VUE<br>
layout and we avoid the tests to crash in this scenario.<br>
<br>
Of course, this is not a proper fix, we'd still run into problems if someone<br>
tries to use an explicit max location and read gl_ViewportIndex, gl_LayerID or<br>
gl_CullDistancein in the FS, but that would be a much less common bug and we<br>
can probably wait to see if anyone actually runs into that situation in a real<br>
world scenario before making the decision that more aggresive changes are<br>
required to support this without reverting 99df02ca26f61.<br>
<br>
Suggested-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
---<br>
src/mesa/drivers/dri/i965/<wbr>genX_state_upload.c | 25 +++++++++++++++++++++++++<br>
1 file changed, 25 insertions(+)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>genX_state_upload.c b/src/mesa/drivers/dri/i965/<wbr>genX_state_upload.c<br>
index 612761601a..ce3515067f 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>genX_state_upload.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>genX_state_upload.c<br>
@@ -1040,6 +1040,31 @@ genX(calculate_attr_overrides)<wbr>(const struct brw_context *brw,<br>
<br>
*urb_entry_read_offset = fs_needs_vue_header ? 0 : 1;<br>
<br>
+ /* If we are already skipping the first 2 slots for the VUE header then we<br>
+ * can also skip clip distances if they are located right after the header<br>
+ * and the FS doesn't read them. Only do this is there are any user varyings<br>
+ * though, since the hardware requires that we pass at least one varying<br>
+ * between stages.<br>
+ */<br>
+ uint64_t var_bits = ~(VARYING_BIT_VAR(0) - 1);<br>
+ uint64_t clip_dist_slots = VARYING_BIT_CLIP_DIST0 | VARYING_BIT_CLIP_DIST1;<br>
+ if (!fs_needs_vue_header &&<br>
+ var_bits &&<br>
+ (brw->fragment_program->info.<wbr>inputs_read & clip_dist_slots) == 0 &&<br>
+ (brw->vue_map_geom_out.slots_<wbr>valid & clip_dist_slots)) {<br>
+<br>
+ uint32_t clip_dist0_slot =<br>
+ brw->vue_map_geom_out.varying_<wbr>to_slot[VARYING_SLOT_CLIP_<wbr>DIST0];<br>
+<br>
+ uint32_t clip_dist1_slot =<br>
+ brw->vue_map_geom_out.varying_<wbr>to_slot[VARYING_SLOT_CLIP_<wbr>DIST1];<br>
+<br>
+ if (clip_dist0_slot >= 2 && clip_dist0_slot <= 3 &&<br>
+ clip_dist1_slot >= 2 && clip_dist1_slot <= 3) {<br>
+ *urb_entry_read_offset = 2;<br>
+ }<br>
+ }<br>
+<br>
/* From the Ivybridge PRM, Vol 2 Part 1, 3DSTATE_SBE,<br>
* description of dw10 Point Sprite Texture Coordinate Enable:<br>
*<br>
<font color="#888888">--<br>
2.11.0<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></blockquote></div><br></div>
</blockquote></body></html>