glsl: Hard-code noise to zero in builtin_functions.cpp
authorJason Ekstrand <jason@jlekstrand.net>
Mon, 20 Apr 2020 17:06:15 +0000 (12:06 -0500)
committerMarge Bot <eric+marge@anholt.net>
Tue, 21 Apr 2020 06:16:13 +0000 (06:16 +0000)
commit4386c06770508d86eaa51839871767887f903d1a
treec6ff2d3cbdf559e3942b106e3d9a871ac6e2c031
parent95f555a93a8891ebba2a291eecd984eb2364d636
glsl: Hard-code noise to zero in builtin_functions.cpp

Version 4.4 of the GLSL spec changed the definition of noise*() to
always return zero and earlier versions of the spec allowed zero as a
valid implementation.

All drivers, as far as I can tell, unconditionally call lower_noise()
today which turns ir_unop_noise into zero.  We've got a 10-year-old
comment in there saying "In the future, ir_unop_noise may be replaced by
a call to a function that implements noise."  Well, it's the future now
and we've not yet gotten around to that.  In the mean time, the GLSL
spec has made doing so illegal.

To make things worse, we then pretend to handle the opcode in
glsl_to_nir, ir_to_mesa, and st_glsl_to_tgsi even though it should never
get there given the lowering.  The lowering in st_glsl_to_tgsi defines
noise*() to be 0.5 which is an illegal implementation of the noise
functions according to pre-4.4 specs.  We also have opcodes for this in
NIR which are never used because, again, we always call lower_noise().

Let's just kill the whole opcode and make builtin_builder.cpp build a
bunch of functions that just return zero.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4624>
16 files changed:
src/compiler/Makefile.sources
src/compiler/glsl/README
src/compiler/glsl/builtin_functions.cpp
src/compiler/glsl/glsl_to_nir.cpp
src/compiler/glsl/ir.cpp
src/compiler/glsl/ir_constant_expression.cpp
src/compiler/glsl/ir_expression_operation.py
src/compiler/glsl/ir_optimization.h
src/compiler/glsl/ir_validate.cpp
src/compiler/glsl/lower_noise.cpp [deleted file]
src/compiler/glsl/meson.build
src/compiler/glsl/test_optpass.cpp
src/mesa/drivers/dri/i965/brw_link.cpp
src/mesa/program/ir_to_mesa.cpp
src/mesa/state_tracker/st_glsl_to_ir.cpp
src/mesa/state_tracker/st_glsl_to_tgsi.cpp