KhronosGroup / SPIRV-Tools

Apache License 2.0
1.05k stars 549 forks source link

spriv-opt - not getting usable half codegen out of GLSL, HLSL much better #4211

Open alecazam opened 3 years ago

alecazam commented 3 years ago

I'm trying to run some really basic shaders using half/min16Float/mediump float/... through glslangValidator, spirv-opt, spriv-cross. The shaders, script, and results are over here:

https://github.com/google/shaderc/issues/1177

This is all based on the work detailed here by Greg Fischer found here. https://www.lunarg.com/wp-content/uploads/2019/09/Automatic-RelaxedPrecision-Decoration-and-Conversion-in-Spirv-Opt_r1.pdf

Was this work completed for GLSL? Was this work completed for HLSL? The best results regarding inputs/outputs was using HLSL. The results I was able to get were better, but it seemed like there were no "half" definitions of functions for either syntax, and that resulted in tons of casting being needed even in HSLSL. On the GLSL side, no support for float16_t, fp16vec/2/3/4 was found. "mediump float" isn't the same since it can't be used in casts like a type/typedef like half/2/3/4.

And other than this effort, what is the recommended way to generate half shaders for mobile platforms? There's very little docs, examples, etc of dealing with this case for Vulkan.

s-perron commented 3 years ago

I don't know if this is the best place to ask this question. It seems like a GLSL question. @greg-lunarg Do you have any advice?