Bug 63132 - [r600/llvm] src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c:1887:lp_emit_declaration_soa: Assertion `idx < 256' failed.
Summary: [r600/llvm] src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c:1887:lp_emit_decl...
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Gallium/r600 (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Default DRI bug account
QA Contact:
URL:
Whiteboard:
Keywords:
: 67046 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-04-04 17:38 UTC by Johannes Obermayr
Modified: 2013-12-09 03:30 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments
R600_DUMP_SHADERS=1 (264.14 KB, text/plain)
2013-04-04 17:38 UTC, Johannes Obermayr
Details
./apitrace trace konqueror (74.28 KB, application/octet-stream)
2013-04-10 15:25 UTC, Johannes Obermayr
Details

Description Johannes Obermayr 2013-04-04 17:38:06 UTC
Created attachment 77438 [details]
R600_DUMP_SHADERS=1

00:01.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Wrestler [Radeon HD 6310] (prog-if 00 [VGA controller])
        Subsystem: ASUSTeK Computer Inc. Device 84a5
        Flags: bus master, fast devsel, latency 0, IRQ 40
        Memory at c0000000 (32-bit, prefetchable) [size=256M]
        I/O ports at f000 [size=256]
        Memory at feb00000 (32-bit, non-prefetchable) [size=256K]
        Expansion ROM at <unassigned> [disabled]
        Capabilities: [50] Power Management version 3
        Capabilities: [58] Express Root Complex Integrated Endpoint, MSI 00
        Capabilities: [a0] MSI: Enable+ Count=1/1 Maskable- 64bit+
        Capabilities: [100] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>
        Kernel driver in use: radeon

Trying to open https://www.shadertoy.com/browse in konqueror.
Comment 1 Michel Dänzer 2013-04-10 07:59:12 UTC
The driver advertises a maximum of 256 temporaries, but the TGSI shader attempts to use more than that.
Comment 2 Jose Fonseca 2013-04-10 09:05:40 UTC
Looking at the TGSI shader in the attachement, it looks like Mesa state tracker is doing an aweful job in allocating TEMP registers: they keep just increasing number, even though there is no indirection of TEMP registers.  I recall that GLSL IR emits increasing indices and Mesa state tracker tries to be a bit smarter, but I suspect that the loop is thwarting it.

Johannes, could you get an apitrace with this?
Comment 3 Jose Fonseca 2013-04-10 09:07:00 UTC
I forgot to say: it's trivial to increase the gallivm TEMP limit from 256 to anything above, but that will do nothing for other non LLVM drivers, e.g., svga.
Comment 4 Johannes Obermayr 2013-04-10 15:25:04 UTC
Created attachment 77756 [details]
./apitrace trace konqueror

I hope apitrace was invoked right ...
Comment 5 Jose Fonseca 2013-04-10 15:54:18 UTC
(In reply to comment #4)
> Created attachment 77756 [details]
> ./apitrace trace konqueror

Thanks.

> I hope apitrace was invoked right ...

Yep, it reproduces the issue fine:

  $ glretrace konqueror.trace
  src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c:1887:lp_emit_declaration_soa: Assertion `idx < 256' failed.
  apitrace: warning: caught signal 5
  1585: error: caught an unhandled exception
  apitrace: info: taking default action for signal 5
  Trace/breakpoint trap


One can see the expected output by doing (on a non-crashing driver like NVIDIA):

  $ glretrace -S 1585/draw konqueror.trace
  Wrote 0000001585.png
  Rendered 0 frames in 0.269629 secs, average of 0 fps

Here are the source shaders:

  $ glretrace -D 1585 konqueror.trace
  [...]
    "GL_FRAGMENT_SHADER": "uniform vec3 iResolution;
uniform float iGlobalTime;
uniform float iChannelTime[4];
uniform vec4 iMouse;
uniform vec4 iDate;
uniform sampler2D iChannel0;
uniform sampler2D iChannel1;
uniform sampler2D iChannel2;
uniform sampler2D iChannel3;
mat3 m = mat3(0.0, 0.80000001, 0.60000002, -0.80000001, 0.36000001, -0.47999999, -0.60000002, -0.47999999, 0.63999999);
float hash(in float n){
return fract((sin(n) * 43758.547));
}
float noise(in vec3 x){
vec3 p = floor(x);
vec3 f = fract(x);
(f = ((f * f) * (3.0 - (2.0 * f))));
float n = ((p[0] + (p[1] * 57.0)) + (113.0 * p[2]));
float res = mix(mix(mix(hash((n + 0.0)), hash((n + 1.0)), f[0]), mix(hash((n + 57.0)), hash((n + 58.0)), f[0]), f[1]), mix(mix(hash((n + 113.0)), hash((n + 114.0)), f[0]), mix(hash((n + 170.0)), hash((n + 171.0)), f[0]), f[1]), f[2]);
return res;
}
float fbm(in vec3 p){
float f;
(f = (0.5 * noise(p)));
(p = ((m * p) * 2.02));
(f += (0.25 * noise(p)));
(p = ((m * p) * 2.03));
(f += (0.125 * noise(p)));
(p = ((m * p) * 2.01));
(f += (0.0625 * noise(p)));
return f;
}
vec4 map(in vec3 p){
float d = (0.2 - p[1]);
(d += (3.0 * fbm(((p * 1.0) - (vec3(1.0, 0.1, 0.0) * iGlobalTime)))));
(d = clamp(d, 0.0, 1.0));
vec4 res = vec4(d);
(res.xyz = mix(vec3(1.15, 1.0925, 0.92000002), vec3(0.69999999, 0.69999999, 0.69999999), res[0]));
return res;
}
vec3 sundir = vec3(-1.0, 0.0, 0.0);
vec4 raymarch(in vec3 ro, in vec3 rd){
vec4 sum = vec4(0.0, 0.0, 0.0, 0.0);
float t = 0.0;
for (int i = 0; (i < 44); (i++))
{
vec3 pos = (ro + (t * rd));
vec4 col = map(pos);
float dif = clamp(((col[3] - map((pos + (0.30000001 * sundir)))[3]) / 0.60000002), 0.0, 1.0);
vec3 brdf = (vec3(0.8775, 0.91800004, 0.94499999) + (vec3(0.315, 0.22499999, 0.13500001) * dif));
(col.xyz *= brdf);
(col[3] *= 0.34999999);
(col.xyz *= col[3]);
(sum = (sum + (col * (1.0 - sum[3]))));
(t += max(0.1, (0.050000001 * t)));
}
(sum.xyz /= (0.001 + sum[3]));
return clamp(sum, 0.0, 1.0);
}
void main(){
vec2 q = (gl_FragCoord.xy / iResolution.xy);
vec2 p = (-1.0 + (2.0 * q));
(p[0] *= (iResolution[0] / iResolution[1]));
vec2 mo = (-1.0 + ((2.0 * iMouse.xy) / iResolution.xy));
vec3 ro = (4.0 * normalize(vec3(cos((2.75 - (3.0 * mo[0]))), (0.69999999 + (mo[1] + 1.0)), sin((2.75 - (3.0 * mo[0]))))));
vec3 ta = vec3(0.0, 1.0, 0.0);
vec3 ww = normalize((ta - ro));
vec3 uu = normalize(cross(vec3(0.0, 1.0, 0.0), ww));
vec3 vv = normalize(cross(ww, uu));
vec3 rd = normalize((((p[0] * uu) + (p[1] * vv)) + (1.5 * ww)));
vec4 res = raymarch(ro, rd);
float sun = clamp(dot(sundir, rd), 0.0, 1.0);
vec3 col = ((vec3(0.60000002, 0.70999998, 0.75) - ((rd[1] * 0.2) * vec3(1.0, 0.5, 1.0))) + 0.075000003);
(col += (vec3(0.2, 0.12, 0.020000001) * pow(sun, 8.0)));
(col *= 0.94999999);
(col = mix(col, res.xyz, res[3]));
(col += (vec3(0.1, 0.040000003, 0.020000001) * pow(sun, 3.0)));
(gl_FragColor = vec4(col, 1.0));
}
",
    "GL_VERTEX_SHADER": "attribute vec2 pos;
void main(){
(gl_Position = vec4(pos[0], pos[1], 0.0, 1.0));
}
"
   [...]
Comment 6 Johannes Obermayr 2013-07-26 15:39:33 UTC
*** Bug 67046 has been marked as a duplicate of this bug. ***
Comment 7 Laurent carlier 2013-12-08 12:02:14 UTC
pixmark_piano_benchmark works since http://cgit.freedesktop.org/mesa/mesa/commit/?id=797894036d1196805f02a2428fff82ece5855af7

It's slow but no more llvm errors
Comment 8 Michel Dänzer 2013-12-09 03:30:21 UTC
Fixed for r600g/radeonsi in Mesa Git master:

commit 797894036d1196805f02a2428fff82ece5855af7
Author: Vincent Lejeune <vljn@ovi.com>
Date:   Mon Dec 2 00:54:44 2013 +0100

    r600/llvm: Allow arbitrary amount of temps in tgsi to llvm


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.