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; }
(In reply to comment #0) > 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; > } Cool. Can you send that as a patch to mesa-dev?
Patch sent: http://lists.freedesktop.org/archives/mesa-dev/2014-August/065661.html
Committed as http://cgit.freedesktop.org/mesa/mesa/commit/?id=2b837576eb47eeb25f381c534a8bbccda0ee4c89
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.