Warning: this repository is a work-in-progress. Things may break while we transition this project to open source. This is not an officially supported Google product.
GraphicsFuzz is a testing framework for automatically finding and simplifying bugs in graphics shader compilers. Our tools currently manipulate GLSL shaders, but we can indirectly test other targets such as SPIR-V, HLSL and Metal. Our current priority is testing Vulkan drivers.
A graphics driver takes a shader program as input and executes it on a GPU (graphics processing unit) to render an image.
Compiling and executing shaders is complex, and many graphics drivers are unreliable: a valid shader can lead to wrong images, driver errors or even security issues.
Automatically finding bugs
We start with a reference shader that renders an image. The reference shader can be any shader you like, such as a high-value shader from a game or existing test suite.
Shaders are programs, so by applying semantics-preserving source code transformations, we can obtain a shader with significantly different source code that still has the same effect.
For example, wrapping code in a single-iteration loop does not change the meaning (semantics) of a program. By applying various semantics-preserving transformations to the reference shader, we generate a family of variant shaders, where each variant must render the same image as the reference.
If a variant shader leads to a seriously different image (or a driver error), then we have found a graphics driver bug!
This approach is known as metamorphic testing.
Finding bugs is not the end of the story: a variant shader that exposes a bug is typically very large (thousands of lines), full of code coming from the semantics-preserving transformations. Typically only a fraction of this code is needed to expose the bug.
Fortunately, our reducer is able to selectively reverse those transformations that are not relevant to the bug. After reduction, we obtain a small difference sufficient to expose the driver issue.
The reduced variant still exposes the bug, and differs from the reference only slightly: this is a great starting point to isolate the root cause of the bug in the graphics driver.
GraphicsFuzz finds bugs in graphics drivers by rendering families of semantically equivalent shaders, and looking for output discrepancies. This approach is known as metamorphic testing. For each bug, the reducer saves a lot of debugging time by producing a simpler minimal-difference test case that still exposes the bug.
GraphicsFuzz blog posts:
- 17 January 2018: Samsung Galaxy S8 (ARM, Qualcomm)
- 22 January 2018: Nvidia Shield TV, Tablet (Nvidia)
- 25 January 2018: Google Pixel Phone 1, 2 (Qualcomm)
- 5 February 2018: Google Nexus Player (Imagination Technologies)
- 15 February 2018: Huawei Honor 9, 9 lite, 10 (ARM)
- 22 February 2018: Apple iPhone 6, 7, 8, X (Apple, Imagination Technologies)
- 12 March 2018: Samsung Galaxy S6, S7 (ARM, Qualcomm)
- 22 May 2018: Samsung Galaxy S9 (ARM, Qualcomm)
Academic research project blog posts:
- 30 November 2016: Intro
- 1 December 2016: AMD
- 7 December 2016: Apple
- 12 December 2016: ARM
- 15 December 2016: Imagination Technologies
- 20 December 2016: Intel
- 25 January 2017: Nvidia
- 1 February 2017: Qualcomm