一句话:提出 FSHADER,用着色器融合等四种蜕变关系测试图形着色器编译器,发现大量错误编译与优化缺陷。
图形着色器编译器负责将高层着色器程序编译优化为 GPU 机器码,其缺陷会导致渲染错误,进而影响 VR、游戏、自动驾驶等生产场景。本文提出 FSHADER,一个面向着色器编译器的蜕变测试(MT)框架:它通过四种精心设计的蜕变关系变异输入着色器程序,核心思路是融合两个着色器程序,并比较融合程序的渲染结果与分别渲染后再融合的图像之间的一致性,从而暴露错误的编译与优化行为。作者在覆盖 Intel、AMD、Nvidia、ARM、Apple 五家 GPU 厂商的 12 个着色器编译器上开展评估,成功发现超过 16K 个触发错误的输入,并人工定位与刻画了出错的优化位置,代表性缺陷已获开发者确认。
Computer graphics are powered by graphics APIs (e.g., OpenGL, Direct3D) and their associated shader compilers, which render high-quality images by compiling and optimizing user-written high-level shader programs into GPU machine code. Graphics rendering is extensively used in production scenarios like virtual reality (VR), gaming, autonomous driving, and robotics. Despite the development by industrial manufacturers such as Intel, Nvidia, and AMD, shader compilers - like traditional software - may produce ill-rendered outputs. In turn, these errors may result in negative results, from poor user experience in entertainment to accidents in driving assistance systems. This paper introduces FSHADER, a metamorphic testing (MT) framework designed specifically for shader compilers to uncover erroneous compilations and optimizations. FSHADER tests shader compilers by mutating input shader programs via four carefully-designed metamorphic relations (MRs). In particular, FSHADER fuses two shader programs via an MR and checks the visual consistency between the image rendered from the fused shader program with the output of fusing individually rendered images. Our study of 12 shader compilers covers five mainstream GPU vendors, including Intel, AMD, Nvidia, ARM, and Apple. We successfully uncover over 16K error-triggering inputs that generate incorrect rendering outputs. We manually locate and characterize buggy optimization places, and developers have confirmed representative bugs.