Bug 99154 - Link time error when using multiple builtin functions
Summary: Link time error when using multiple builtin functions
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Kenneth Graunke
QA Contact: Intel 3D Bugs Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-19 21:26 UTC by Niels Ole Salscheider
Modified: 2016-12-21 04:56 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Simple test case (123 bytes, text/plain)
2016-12-19 21:26 UTC, Niels Ole Salscheider
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Niels Ole Salscheider 2016-12-19 21:26:25 UTC
Created attachment 128570 [details]
Simple test case

When using multiple builtin functions, linking of a shader can fail if temporary variables of the GLSL compiler collide.

builtin_builder::binop creates variables named "x" and "y" for the parameters of builtin functions. Later, ir_call::generate_inline inlines the call to the builtins. It clones the variables (without changing the name) and assigns the function inputs to them.

This can cause a collision of variable names, e. g. when using multiple builtin functions with parameters of different types. The attached test case can be used to reproduce the problem.

I can work around the problem by adding a sequence number and possibly a prefix to the variable names but I am not sure if that is the correct solution.

Thanks to imirkin and robclark for helping me to figure this out on IRC.
Comment 1 Kenneth Graunke 2016-12-19 23:32:32 UTC
Patch on list:
https://lists.freedesktop.org/archives/mesa-dev/2016-December/138613.html
Comment 2 Kenneth Graunke 2016-12-21 04:56:36 UTC
Fixed on master:

commit 62b8bcda1cb7ad18acee7042d40c01b56385e124
Author: Kenneth Graunke <kenneth@whitecape.org>
Date:   Mon Dec 19 14:32:57 2016 -0800

    glsl: Use ir_var_temporary when generating inline functions.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.