Hash :
f9d261f5
Author :
Date :
2021-08-25T10:23:48
Translator: Don't promote precision from initializer
Take the following GLSL code:
precision mediump float;
uniform highp float u;
float x = u;
When `x` is declared, its precision is mediump due to
`precision mediump float`. Its initializer (`u`) however is highp.
Previously, ANGLE generated the following code to ensure the precision
of the initializer is applied to the variable:
highp float x = u;
Compiling the same code with glslang and looking at the SPIR-V (both
SPIR-V for OpenGL and SPIR-V for Vulkan), such a promotion is not done.
The generated SPIR-V is equivalent to:
mediump float x = u;
This change aligns ANGLE's output with glslang's by outputting the
precision of the variable itself instead of the precision of the
assignment (which is highp due to promotion from the two operands).
Bug: angleproject:4889
Bug: angleproject:6132
Change-Id: I6f338a865c0a7710329fc13bc171fd245dd30b31
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3118965
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>