Re: [Mesa-dev] RFC Steps towards replacing the GLSL IR optimisations with NIR
On Wed, 2016-07-20 at 20:57 +1000, Timothy Arceri wrote: > Currently disabling these optimisations causes some major regressions > mainly > because cross shader removal of unused varyings is done in the GLSL > IR linker. > > I've spent some time today attempting to insert a glsl->nir > conversion just > before assigning varying locations. The idea was I could then call > some nir > optimisations, check what varyings are left in nir then remove the > varyings > from the producing GLSL IR stage and continue on (this happens in FS- > >VS order). > Ideally we would use the GLSL IR for validation and PIQ and would be > able to > hold onto the nir and reuse it in the backend. We should also be able > to do > the same for unused uniforms but thats not as useful. > > Unfortunatly the order in which we do things currently e.g lowering > UBOs > after running link_uniforms is making things difficult and I dont yet > have a solid plan to solve all the issues. However in order to create > the nir I needed to first call the drivers GLSL processing pass and > this > proved to do a nice job of removing a bunch of instructions itself so > I'm sending this as a first step. > > Broadwell shader-db results: > > total instructions in shared programs: 8649621 -> 8642352 (-0.08%) > instructions in affected programs: 49023 -> 41754 (-14.83%) > total loops in shared programs:2087 -> 2087 (0.00%) > helped:359 > HURT: 5 > GAINED:0 > LOST: 0 > > There are two piglit tests failing with these changes: > > tests/spec/arb_gpu_shader5/execution/samplemaskin- > indirect.shader_test > Fails because the uniform is now optimised away an can no longer be > found. > > tests/spec/glsl-1.50/execution/geometry/max-input- > components.shader_test > Fails to link on hsw, snb and ivb. There is no error message linking > just > fails, I'm still looking into the problem. It seems the vec4 backend fails to spill registers when compiling the gs. > > Full shader-db results bellow in case anyone wants to dig further > into these results. > > helped: shaders/closed/steam/tropico-5/99.shader_test FS SIMD16: > 591 -> 590 (-0.17%) > helped: shaders/closed/UnrealEngine4/VehicleGame/42.shader_test FS > SIMD16: 362 -> 361 (-0.28%) > helped: shaders/closed/steam/dota-2-reborn/1641.shader_test FS > SIMD16: 334 -> 333 (-0.30%) > helped: shaders/closed/steam/dota-2-reborn/1925.shader_test FS > SIMD16: 327 -> 326 (-0.31%) > helped: shaders/closed/steam/dota-2-reborn/1933.shader_test FS > SIMD16: 326 -> 325 (-0.31%) > helped: shaders/closed/steam/dota-2-reborn/1967.shader_test FS > SIMD16: 315 -> 314 (-0.32%) > helped: shaders/closed/steam/dota-2-reborn/1845.shader_test FS > SIMD16: 313 -> 312 (-0.32%) > helped: shaders/closed/steam/dota-2-reborn/1717.shader_test FS > SIMD16: 304 -> 303 (-0.33%) > helped: shaders/closed/UnrealEngine4/ReflectionsSubwayDemo/282.shad > er_test FS SIMD16: 250 -> 249 (-0.40%) > helped: shaders/closed/steam/metro-2033-redux/3274.shader_test VS > SIMD8: 221 -> 220 (-0.45%) > helped: shaders/closed/steam/metro-2033-redux/6530.shader_test VS > SIMD8: 215 -> 214 (-0.47%) > helped: shaders/closed/steam/metro-2033-redux/6528.shader_test VS > SIMD8: 215 -> 214 (-0.47%) > helped: shaders/closed/steam/metro-2033-redux/5977.shader_test VS > SIMD8: 214 -> 213 (-0.47%) > helped: shaders/closed/steam/metro-2033-redux/4775.shader_test VS > SIMD8: 214 -> 213 (-0.47%) > helped: shaders/closed/steam/metro-2033-redux/5603.shader_test VS > SIMD8: 214 -> 213 (-0.47%) > helped: shaders/closed/steam/metro-2033-redux/5605.shader_test VS > SIMD8: 214 -> 213 (-0.47%) > helped: shaders/closed/steam/metro-2033-redux/4943.shader_test VS > SIMD8: 213 -> 212 (-0.47%) > helped: shaders/closed/steam/metro-2033-redux/4774.shader_test VS > SIMD8: 211 -> 210 (-0.47%) > helped: shaders/closed/steam/metro-2033-redux/4773.shader_test VS > SIMD8: 211 -> 210 (-0.47%) > helped: shaders/closed/steam/metro-2033-redux/4648.shader_test VS > SIMD8: 208 -> 207 (-0.48%) > helped: shaders/closed/steam/metro-2033-redux/6529.shader_test VS > SIMD8: 207 -> 206 (-0.48%) > helped: shaders/closed/steam/metro-2033-redux/3275.shader_test VS > SIMD8: 207 -> 206 (-0.48%) > helped: shaders/closed/steam/metro-2033-redux/2478.shader_test VS > SIMD8: 206 -> 205 (-0.49%) > helped: shaders/closed/steam/metro-2033-redux/5604.shader_test VS > SIMD8: 206 -> 205 (-0.49%) > helped: shaders/closed/steam/metro-2033-redux/2479.shader_test VS > SIMD8: 206 -> 205 (-0.49%) > helped: shaders/closed/steam/metro-2033-redux/5976.shader_test VS > SIMD8: 206 -> 205 (-0.49%) > helped: shaders/closed/steam/metro-2033-redux/4942.shader_test VS > SIMD8: 205 -> 204 (-0.49%) > helped: shaders/closed/steam/metro-2033-redux/4941.shader_test VS > SIMD8: 205 -> 204 (-0.49%) > helped:
[Mesa-dev] RFC Steps towards replacing the GLSL IR optimisations with NIR
Currently disabling these optimisations causes some major regressions mainly because cross shader removal of unused varyings is done in the GLSL IR linker. I've spent some time today attempting to insert a glsl->nir conversion just before assigning varying locations. The idea was I could then call some nir optimisations, check what varyings are left in nir then remove the varyings from the producing GLSL IR stage and continue on (this happens in FS->VS order). Ideally we would use the GLSL IR for validation and PIQ and would be able to hold onto the nir and reuse it in the backend. We should also be able to do the same for unused uniforms but thats not as useful. Unfortunatly the order in which we do things currently e.g lowering UBOs after running link_uniforms is making things difficult and I dont yet have a solid plan to solve all the issues. However in order to create the nir I needed to first call the drivers GLSL processing pass and this proved to do a nice job of removing a bunch of instructions itself so I'm sending this as a first step. Broadwell shader-db results: total instructions in shared programs: 8649621 -> 8642352 (-0.08%) instructions in affected programs: 49023 -> 41754 (-14.83%) total loops in shared programs:2087 -> 2087 (0.00%) helped:359 HURT: 5 GAINED:0 LOST: 0 There are two piglit tests failing with these changes: tests/spec/arb_gpu_shader5/execution/samplemaskin-indirect.shader_test Fails because the uniform is now optimised away an can no longer be found. tests/spec/glsl-1.50/execution/geometry/max-input-components.shader_test Fails to link on hsw, snb and ivb. There is no error message linking just fails, I'm still looking into the problem. Full shader-db results bellow in case anyone wants to dig further into these results. helped: shaders/closed/steam/tropico-5/99.shader_test FS SIMD16: 591 -> 590 (-0.17%) helped: shaders/closed/UnrealEngine4/VehicleGame/42.shader_test FS SIMD16: 362 -> 361 (-0.28%) helped: shaders/closed/steam/dota-2-reborn/1641.shader_test FS SIMD16: 334 -> 333 (-0.30%) helped: shaders/closed/steam/dota-2-reborn/1925.shader_test FS SIMD16: 327 -> 326 (-0.31%) helped: shaders/closed/steam/dota-2-reborn/1933.shader_test FS SIMD16: 326 -> 325 (-0.31%) helped: shaders/closed/steam/dota-2-reborn/1967.shader_test FS SIMD16: 315 -> 314 (-0.32%) helped: shaders/closed/steam/dota-2-reborn/1845.shader_test FS SIMD16: 313 -> 312 (-0.32%) helped: shaders/closed/steam/dota-2-reborn/1717.shader_test FS SIMD16: 304 -> 303 (-0.33%) helped: shaders/closed/UnrealEngine4/ReflectionsSubwayDemo/282.shader_test FS SIMD16: 250 -> 249 (-0.40%) helped: shaders/closed/steam/metro-2033-redux/3274.shader_test VS SIMD8: 221 -> 220 (-0.45%) helped: shaders/closed/steam/metro-2033-redux/6530.shader_test VS SIMD8: 215 -> 214 (-0.47%) helped: shaders/closed/steam/metro-2033-redux/6528.shader_test VS SIMD8: 215 -> 214 (-0.47%) helped: shaders/closed/steam/metro-2033-redux/5977.shader_test VS SIMD8: 214 -> 213 (-0.47%) helped: shaders/closed/steam/metro-2033-redux/4775.shader_test VS SIMD8: 214 -> 213 (-0.47%) helped: shaders/closed/steam/metro-2033-redux/5603.shader_test VS SIMD8: 214 -> 213 (-0.47%) helped: shaders/closed/steam/metro-2033-redux/5605.shader_test VS SIMD8: 214 -> 213 (-0.47%) helped: shaders/closed/steam/metro-2033-redux/4943.shader_test VS SIMD8: 213 -> 212 (-0.47%) helped: shaders/closed/steam/metro-2033-redux/4774.shader_test VS SIMD8: 211 -> 210 (-0.47%) helped: shaders/closed/steam/metro-2033-redux/4773.shader_test VS SIMD8: 211 -> 210 (-0.47%) helped: shaders/closed/steam/metro-2033-redux/4648.shader_test VS SIMD8: 208 -> 207 (-0.48%) helped: shaders/closed/steam/metro-2033-redux/6529.shader_test VS SIMD8: 207 -> 206 (-0.48%) helped: shaders/closed/steam/metro-2033-redux/3275.shader_test VS SIMD8: 207 -> 206 (-0.48%) helped: shaders/closed/steam/metro-2033-redux/2478.shader_test VS SIMD8: 206 -> 205 (-0.49%) helped: shaders/closed/steam/metro-2033-redux/5604.shader_test VS SIMD8: 206 -> 205 (-0.49%) helped: shaders/closed/steam/metro-2033-redux/2479.shader_test VS SIMD8: 206 -> 205 (-0.49%) helped: shaders/closed/steam/metro-2033-redux/5976.shader_test VS SIMD8: 206 -> 205 (-0.49%) helped: shaders/closed/steam/metro-2033-redux/4942.shader_test VS SIMD8: 205 -> 204 (-0.49%) helped: shaders/closed/steam/metro-2033-redux/4941.shader_test VS SIMD8: 205 -> 204 (-0.49%) helped: shaders/closed/steam/metro-2033-redux/3910.shader_test VS SIMD8: 205 -> 204 (-0.49%) helped: shaders/closed/steam/metro-2033-redux/4650.shader_test VS SIMD8: 202 -> 201 (-0.50%) helped: shaders/closed/steam/metro-2033-redux/5811.shader_test VS SIMD8: 201 -> 200 (-0.50%) helped: shaders/closed/steam/metro-2033-redux/4649.shader_test VS SIMD8: 199 -> 198