[Mesa-dev] [PATCH] linker: Only over-ride built-ins when a prototype has been seen

Chad Versace chad at chad-versace.us
Wed Jul 13 15:49:13 PDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/11/2011 10:50 AM, Ian Romanick wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
> 
> The GLSL spec says:
> 
>     "If a built-in function is redeclared in a shader (i.e., a
>     prototype is visible) before a call to it, then the linker will
>     only attempt to resolve that call within the set of shaders that
>     are linked with it."
> 
> This patch enforces this behavior.  When a function call is processed
> a flag is set in the ir_call to indicate whether the previously seen
> prototype is the built-in or not.  At link time a call will only bind
> to an instance of a function that matches the "want built-in" setting
> in the ir_call.
> 
> This has the odd side effect that first call to abs() in the shader
> below will call the built-in and the second will not:
> 
> float foo(float x) { return abs(x); }
> float abs(float x) { return -x; }
> float bar(float x) { return abs(x); }
> 
> This seems insane, but it matches what the spec says.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=31744
> ---
>  src/glsl/ir.h               |    4 ++++
>  src/glsl/link_functions.cpp |   22 +++++++++++++++++-----
>  2 files changed, 21 insertions(+), 5 deletions(-)


This patch causes link failures in the following tests:

glsl/overide-builtin
spec/glsl-1.10/linker/overide-builtin-const-02
spec/glsl-1.10/linker/overide-builtin-const-04
spec/glsl-1.10/linker/overide-builtin-const-08
spec/glsl-1.10/linker/overide-builtin-uniform-02
spec/glsl-1.10/linker/overide-builtin-uniform-04
spec/glsl-1.10/linker/overide-builtin-uniform-08

- -- 
Chad Versace
chad at chad-versace.us
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOHiDpAAoJEAIvNt057x8ioYsP/1Ctgi6JTpmr5BccRF9r92vF
0zO2vHIc8E9r+k9RGg/v0jwtxJdn8LDLmskQQ6Bg0aH1U8wi8th50Qb00jmfZXkw
mZgF/YpiQ/iy3mTxakv17aBRyZHjisdQBD+pGifluHExYiRyia1URAnEqQon/D/a
WTgO7WeiDlrwINdjN9nmv0BYac0GH7WkP6q9zss4EwSFvYWHtagiGC4GXqUtvSGW
ZeM8j+bssXGhSEZEK4ufW264ZpEkn+UFkOp1bAvZ5k97lcdycDhaQYmhdMyGqFua
heq9Od0X6IUGcY3KnLJ9IsWXzZL/R1G0KziCotQ1fC9W+fgcZlpI+l1OZ/iRYX3z
v0dybMCltFanUOI8s3GzghMg7mcyapZvcXAH/zcSylHnGI3PV+6cshjaekQFTWgY
C77LDpiUKrBWYeoI7nWpGtJVWIUNW20raDNqwSlrkejsAII/ly3BHKhphI3kCGI2
Tc5uhI7Fn+gl1GhmlbMIfTSlJfuSarCshTtsq78JnZbm5YmY9Z0+qs1ZrINYzQLD
g/C1VEoQcGuqDGJ3TfkVuNFkaZ3C+LH2n6sNhizHkLqh3gjD0nV1yqQGrUu4e9Ys
+5FOFPEonP/qK45KyLOUiU+/itlInBbn69c+ARePbCOmHOfgIHAm2EeC9t20dy4v
ZuhQn9gj2fTyGvKARJbi
=/ErH
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list