google / graphicsfuzz

A testing framework for automatically finding and simplifying bugs in graphics shader compilers.
Apache License 2.0
570 stars 117 forks source link

gfauto reduction not semantically same #1110

Closed tsalmivalli closed 3 years ago

tsalmivalli commented 3 years ago

Few Graphicsfuzz bad image reduction results have semantically different reference and variant shaders.

Code block bellow is the diffrence between the reference and variant shaders. The switch case in the function GLF_live5patternize always ends up into case 2 that has discard in it. Whenever the function is called, it discards the pixel. The shaders are no longer semantically same.

float GLF_live5patternize(vec2 GLF_live5uv)
{
 // 7.3 mod 5.0 typecasted to int equals 2
 switch(int(mod((vec4(1.0, 7.3, 1.0, 1.0)).y, 5.0)))
  {
   case 0:
   return mix(pow(vec2(1.0).x, vec2(1.0).y), vec2(1.0).x, vec2(1.0).y);
   break;
   case 1:
   return mix(pow(vec2(1.0).y, vec2(1.0).y), vec2(1.0).y, vec2(1.0).x);
   break;
   case 2:
   discard;
   break;
   case 3:
   return mix(pow(vec2(1.0).y, vec2(1.0).y), vec2(1.0).y, vec2(1.0).y);
   break;
   case 4:
   return mix(pow(vec2(1.0).y, vec2(1.0).y), vec2(1.0).x, vec2(1.0).x);
   break;
  }
}

...

vec3 GLF_live5color = vec3(GLF_live5patternize(vec2(1.0)));

Drive file name: Graphicsfuzz_discard.zip