Bug 101562

Summary: Fetching from imageBuffer creates very poor GEN assembly
Product: Mesa Reporter: Kevin Rogovin <kevin.rogovin>
Component: Drivers/DRI/i965Assignee: Intel 3D Bugs Mailing List <intel-3d-bugs>
Status: RESOLVED MOVED QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: normal    
Priority: medium CC: eero.t.tamminen
Version: 17.1   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: tarball of results: .shader.txt is input shader, .asm.txt is outout of INTEL_DEBUG=fs

Description Kevin Rogovin 2017-06-23 07:30:47 UTC
Created attachment 132153 [details]
tarball of results: .shader.txt is input shader, .asm.txt is outout of INTEL_DEBUG=fs

If one uses an imageBuffer to fetch values and add them in either of the forms:

 value = start_value + get_value(0) + get_value(1) + ... 
or
 value = ((((((...(start_value + get_value(0)) + get_value(1)) + ... )

then the generated assembly is quite poor. It reserves O(n) registers (where n is the number of constants to fetch) at shader start, with those values placed into the registers having a large number of duplicates.

However, if the shader is:

 value = start_value;
 value += get_value(0);
 value += get_value(1); 

or if the constants are fetched though other means (UBO, TBO, SSBO) then the generated assembly is fine. This is in spite of the fact that the above is equivalent to the 2nd form of a one line add.

Attached is a battery of machine generated shaders and the output of INTEL_DEBUG=fs when compiling such shaders with a matching, but trivial, vertex shader.
Comment 1 GitLab Migration User 2019-09-25 19:02:52 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/mesa/mesa/issues/1604.

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.