<html>
<head>
<base href="https://bugs.freedesktop.org/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - GLSL: opt_vectorize goes wrong on texture lookups"
href="https://bugs.freedesktop.org/show_bug.cgi?id=82574">82574</a>
</td>
</tr>
<tr>
<th>Assignee</th>
<td>idr@freedesktop.org
</td>
</tr>
<tr>
<th>Summary</th>
<td>GLSL: opt_vectorize goes wrong on texture lookups
</td>
</tr>
<tr>
<th>QA Contact</th>
<td>intel-3d-bugs@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Reporter</th>
<td>aras@unity3d.com
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Version</th>
<td>git
</td>
</tr>
<tr>
<th>Component</th>
<td>glsl-compiler
</td>
</tr>
<tr>
<th>Product</th>
<td>Mesa
</td>
</tr></table>
<p>
<div>
<pre>Looks like opt_vectorize is too eager on texture lookups. For example, a shader
like this (which does a color correction effect by looking up R,G,B channels
into a ramp texture):
uniform sampler2D _MainTex;
uniform sampler2D _RampTex;
varying vec2 varUV;
void main()
{
vec4 orig = texture2D (_MainTex, varUV);
float rr = texture2D (_RampTex, orig.xx).x;
float gg = texture2D (_RampTex, orig.yy).y;
float bb = texture2D (_RampTex, orig.zz).z;
vec4 color = vec4 (rr, gg, bb, orig.w);
gl_FragData[0] = color;
}
These 3 lookups effectively get vectorized into something like a:
t.xyz = texture2DProj (_RampTex, t.xyz).xyz;
I can make this bug go away by stopping vectorizing on texture samples, i.e.
adding something like this to opt_vectorize.cpp:
/**
* Upon entering an ir_texture, remove the current assignment from
* further consideration. Vectorizing multiple texture lookups into one
* is wrong.
*/
ir_visitor_status
ir_vectorize_visitor::visit_enter(ir_texture *)
{
this->current_assignment = NULL;
return visit_continue_with_parent;
}</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the QA Contact for the bug.</li>
</ul>
</body>
</html>