<div dir="ltr">On 8 April 2013 10:57, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 04/06/2013 07:49 PM, Paul Berry wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
When a varying is consumed by transform feedback, but is not used by<br>
the fragment shader, assign_varying_locations() sets its interpolation<br>
type to "flat" in order to ensure that lower_packed_varyings never has<br>
to deal with non-flat integral varyings (the GLSL spec doesn't require<br>
integral vertex outputs to be flat if they aren't consumed by the<br>
fragment shader).<br>
<br>
A similar situation will arise when geometry shader support is added,<br>
since the GLSL spec only requires integral vertex shader outputs to be<br>
flat when they are consumed by the geometry shader. This patch<br>
</blockquote></div>
^^^^^^^^<br>
fragment?</blockquote><div><br></div><div>Oops, yes. Thanks.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
modifies the linker to handle this situation too.<br>
---<br>
src/glsl/link_varyings.cpp | 30 ++++++++++++++++++++----------<br>
1 file changed, 20 insertions(+), 10 deletions(-)<br>
<br>
diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp<br>
index 431d8fd..7e90beb 100644<br>
--- a/src/glsl/link_varyings.cpp<br>
+++ b/src/glsl/link_varyings.cpp<br>
@@ -541,7 +541,7 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog,<br>
class varying_matches<br>
{<br>
public:<br>
- varying_matches(bool disable_varying_packing);<br>
+ varying_matches(bool disable_varying_packing, bool consumer_is_fs);<br>
~varying_matches();<br>
void record(ir_variable *producer_var, ir_variable *consumer_var);<br>
unsigned assign_locations();<br>
@@ -621,11 +621,15 @@ private:<br>
* it was allocated.<br>
*/<br>
unsigned matches_capacity;<br>
+<br>
+ const bool consumer_is_fs;<br>
};<br>
<br>
<br>
-varying_matches::varying_<u></u>matches(bool disable_varying_packing)<br>
- : disable_varying_packing(<u></u>disable_varying_packing)<br>
+varying_matches::varying_<u></u>matches(bool disable_varying_packing,<br>
+ bool consumer_is_fs)<br>
+ : disable_varying_packing(<u></u>disable_varying_packing),<br>
+ consumer_is_fs(consumer_is_fs)<br>
{<br>
/* Note: this initial capacity is rather arbitrarily chosen to be large<br>
* enough for many cases without wasting an unreasonable amount of space.<br>
@@ -672,12 +676,12 @@ varying_matches::record(ir_<u></u>variable *producer_var, ir_variable *consumer_var)<br>
return;<br>
}<br>
<br>
- if (consumer_var == NULL) {<br>
- /* Since there is no consumer_var, the interpolation type of this<br>
- * varying cannot possibly affect rendering. Also, since the GL spec<br>
- * only requires integer varyings to be "flat" when they are fragment<br>
- * shader inputs, it is possible that this variable is non-flat and is<br>
- * (or contains) an integer.<br>
+ if (consumer_var == NULL || !consumer_is_fs) {<br>
+ /* Since this varying is not being consumed by the fragment shader, its<br>
+ * interpolation type varying cannot possibly affect rendering. Also,<br>
+ * since the GL spec only requires integer varyings to be "flat" when<br>
+ * they are fragment shader inputs, it is possible that this variable is<br>
+ * non-flat and is (or contains) an integer.<br>
*<br>
* lower_packed_varyings requires all integer varyings to flat,<br>
* regardless of where they appear. We can trivially satisfy that<br>
@@ -685,6 +689,11 @@ varying_matches::record(ir_<u></u>variable *producer_var, ir_variable *consumer_var)<br>
*/<br>
producer_var->centroid = false;<br>
producer_var->interpolation = INTERP_QUALIFIER_FLAT;<br>
+<br>
+ if (consumer_var) {<br>
+ consumer_var->centroid = false;<br>
+ consumer_var->interpolation = INTERP_QUALIFIER_FLAT;<br>
+ }<br>
}<br>
<br>
if (this->num_matches == this->matches_capacity) {<br>
@@ -979,7 +988,8 @@ assign_varying_locations(<u></u>struct gl_context *ctx,<br>
{<br>
const unsigned producer_base = VARYING_SLOT_VAR0;<br>
const unsigned consumer_base = VARYING_SLOT_VAR0;<br>
- varying_matches matches(ctx->Const.<u></u>DisableVaryingPacking);<br>
+ varying_matches matches(ctx->Const.<u></u>DisableVaryingPacking,<br>
+ consumer && consumer->Type == GL_FRAGMENT_SHADER);<br>
hash_table *tfeedback_candidates<br>
= hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare);<br>
hash_table *consumer_inputs<br>
<br>
</blockquote>
<br>
</div></div></blockquote></div><br></div></div>