Bisected to: mesa ee02a5e330151630be871decde563ddbf192465c prog_hash_table: Convert to using util/hash_table.h. Improves glretrace -b servo.trace (a trace of Mozilla's servo rendering engine booting, rendering a page, and exiting) from 1.8s to 1.1s. It uses a large uniform array of structs, making a huge number of separate program resources, and the fixed-size hash table was killing it. Given how many times we've improved performance by swapping the hash table to util/hash_table.h, just do it once and for all. This just rebases the old hash table API on top of util/, for minimal diff. Cleaning things up is left for later, particularly because I want to fix up the new hash table API a little bit. v2: Add UNUSED to the now-unused parameter. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com> Standard Output /tmp/build_root/m64/lib/piglit/bin/glslparsertest /tmp/build_root/m64/lib/piglit/tests/spec/glsl-1.30/compiler/switch-statement/switch-case-duplicated.vert fail 1.30 Shader source: // [config] // expect_result: fail // glsl_version: 1.30 // [end config] // // From page 57 (page 63 of the PDF) of the GLSL 1.30 spec: // // "It is an error to have more than one default or a replicated // constant-expression." #version 130 void main() { int tmp = 0; switch (1) { case 0: case 0: tmp = 1; } gl_Position = vec4(0.0); } Standard Error Successfully compiled vertex shader /tmp/build_root/m64/lib/piglit/tests/spec/glsl-1.30/compiler/switch-statement/switch-case-duplicated.vert:
*** Bug 97326 has been marked as a duplicate of this bug. ***
The problem here is they way switch label hashtable is built, it uses case label as the key and in the test this key is '0'. Now when new hash table searches entries it has a check 'entry_is_present' that checks if key != NULL and this fails in the particular case where case label is 0. One easy way is just to store key + 1 to avoid using 0, I'll investigate if there would be nicer way.
> One easy way is just to store key + 1 to avoid using 0 Which would obviously fail when value is -1 :) Anyway, basic idea would be to avoid using 0 as key.
I believe I have a working fix (uses _mesa_hash_data for key), will run testing and send to mesa-dev if no regressions.
fixed by: --- 8< --- commit 68233801aeb73961cd47dbba276e5d6fcf5411fc Author: Tapani Pälli <tapani.palli@intel.com> Date: Fri Aug 19 13:44:54 2016 +0300 glsl: fix key used for hashing switch statement cases Implementation previously used value itself as the key, however after hash implementation change by ee02a5e we cannot use 0 as key. v2: use constant pointer as the key and implement comparison for contents (Eric Anholt) Signed-off-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Eric Anholt <eric@anholt.net> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97309
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.