Hash :
c1cdc2b5
Author :
Date :
2025-08-22T15:23:58
Transform SPIRV to use 16-bit float for lower precision uniforms This change adds a ShCompileOption flag transformFloatUniformTo16Bits. The flag is turned on in vulkan backends where VK_KHR_16bit_storage extension is supported, and uniformAndStorageBuffer16BitAccess feature is supported. When the compiler flag is turned on, in the generated SPIRV, float data types in mediump and lowp uniforms are transformed from 32-bit to 16-bit. The 16-bit float uniform data is converted to 32-bit with OpFConvert instruction upon loading in SPIRV, this is to minimize the changes in OutputSPIRV.cpp. The converted variable is decorated with RelaxedPrecision, so that SPIRV compiler should be able to treat the converted variable as 16 bits, and the hardware can still benefit from reduced precision floats. The frontend is also notified such SPIRV shader changes by setting the isFloat16 bit in CollectVariables() step, and the frontend will transform float uniform data from 32-bit to 16-bit before storing the data into memory. That way, the uniform data that SPIRV shader reads matches with the uniform data type transformed in the SPIRV shader. This change also updates some test code to allow relative 2^-10 precision wiggle room for mediump uniform floats. This is valid according to spec: https://developer.arm.com/documentation/102502/0101/Shader-precision Bug: angleproject:405795981 Bug: angleproject:440941211 Change-Id: I05db7f5ef744df513fbad87cfed8aa173890ec26 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6851560 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Yuxin Hu <yuxinhu@google.com>