Fetching from imageBuffer creates very poor GEN assembly
Submitted by Kevin Rogovin
Assigned to Intel 3D Bugs Mailing List
Link to original bug (#101562)
Description
Created attachment 132153 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.
Attachment 132153, "tarball of results: .shader.txt is input shader, .asm.txt is outout of INTEL_DEBUG=fs":
test.tar.gz
Version: 17.1