KhronosGroup / KhronosGroup/SPIRV-Tools

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

Open
#4,211 1 comment 0 reactions 0 assignees View on GitHub
component:optimization
Dominant language
C++
Stars
1.4k
Forks
709
Avg merge
1d 22h
Merged PRs (30d)
28

Description

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.

Contributor guide

Open the contributing guide

Research direction

Start with the shader examples, script, and results linked in shaderc issue #1177, then read the referenced SPIR-V optimizer paper. Compare the GLSL and HLSL behavior described there and establish whether the requested half-precision support exists; document the supported path or the remaining implementation scope.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.