Skip to content

i965: Enable software support for ARB_gpu_shader_fp64/ARB_gpu_shader_int64

Matt Turner requested to merge mattst88/mesa:fp64 into master

Some upcoming Intel platforms do not have 64-bit type support. This series implements support for ARB_gpu_shader_fp64 and ARB_gpu_shader_int64 via software implementations.

To do this we add a .glsl file containing GLSL implementations of various 64-bit operations (e.g., double-precision addition) and compile them to NIR when we see that the "user shader" uses some 64-bit operations. Lowering is done in nir_lower_doubles() but a little differently than normal: we convert the to-be-lowered operations into function calls of the software routines and ultimately inline the code. In the future we may wish to use real function calls.

I have a few known test failures (seem to be mostly about ARB_enhanced_layouts -- which makes since given that we're faking 64-bit types) but I think this is good enough to merge. I hope after review you will agree!

Thanks

The GLSL code is based on the Berkeley SoftFloat library (http://www.jhauser.us/arithmetic/SoftFloat.html) which is licensed under the 3-clause BSD license. Many thanks to its authors (John Hauser, et al) for a great and surprisingly readable implementation of some pretty tricky operations.

Work from Elie Tournier's GSoC was leveraged (Thanks a ton, Elie!). He did a great job and I think only a single bug in his GLSL was discovered during this project.

Thanks also to Ian Romanick for some great work he did on lowering memory requirements in nir/phi_builder. That work was critical to allowing me to run the whole test suite and continue my work.

Ian also chipped in a nice Python script (xxd.py) to convert the aforementioned .glsl code into a C string literal that could be built directly into the driver. Dylan used his Python expertise to massage the script to be compatible with both Python2 and Python3. Thanks Dylan! (And again, Ian)

Sagar Ghuge did some great work implementing the last eight or so conversion (e.g., int64 -> double) functions while I was trying to get other ducks in a row. He was a huge help and I'm glad to have him on the Mesa team at Intel. Thanks Sagar!

Some patches from Tim Arceri found their way into my series as well. He wrote the original implementation of glsl-to-nir's function support which I sadly had to entirely rewrite after multiple NIR reworks in the last few months. In any case, his contributions were incredibly helpful to me in getting this project off the ground. Thanks Tim!

Mark Janes and Clayton Craft deserve much praise as well for their work on our CI system at Intel. They have built something that has increased the effectiveness of the team by an order of magnitude and without it I'd still be waiting on my piglit run to finish from last week and would be nowhere near finished with this project. Thanks!

Thanks go to Jason Ekstrand, Ken Graunke, and Ian Romanick for giving me lots of advice and guidance on how to plan this project, structure this code, and help me debug really irritating issues when I was 100% sure I was too sick of the project to grind it out.

Edited by Matt Turner

Merge request reports