In some situations (I'm not exactly sure what) if you use the unary negate operator in one of the arguments to a function then Mesa generates opcodes which do the negation twice (once in a MOV and once as part of a swizzle). For example, something like this: vec3 vec_a; vec3 vec_b; /* .... */ float result = dot(-vec_a, vec_b); generates the following instructions: MOV TEMP[1].xyz, TEMP[1].-x-y-z-w; <-- negation once with MOV MOV (-1 -0 -0 -0) DP3 TEMP[0].w, TEMP[1].-x-y-z-w, UNIFORM[1]; <-- negation again with swizzle DP3 -1 = (1 0 0) . (-1 0 0) Attached is a test for piglit.
Created attachment 37276 [details] [review] Add a shader which does a negation as one of the arguments to dot This is basically doing: vec3 a_vec; vec3 b_vec; /* some random calculations */ float result = dot(-a_vec, b_vec); But for some reason it currently gets compiled as if it was: vec3 a_vec; vec3 b_vec; /* some random calculations */ float result = dot(--a_vec, b_vec); Ie, the negation gets done twice.
I added this test case to piglit, but it seems to pass with both i965 and swrast. It seems likely that this was fixed somewhere over the last 5 months, but who knows which commit did it.
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.