[Mesa-dev] intel: FS compile failed: no register to spill
Johannes Stezenbach
js at sig21.net
Wed Oct 10 09:02:47 PDT 2012
Hi,
I'm experimenting with texture interpolation and seeing this error:
Mesa 8.0.4 implementation error: Failed to compile fragment shader: FS compile failed: no register to spill
Please report at bugs.freedesktop.org
It seems the issue is already known, I found
https://bugs.freedesktop.org/show_bug.cgi?id=48375
and
http://code.google.com/p/chromium-os/issues/detail?id=28524
I'm using Debian unstable amd64 on Sandy Bridge Core i5-2400S.
It seems the fix for the chromium-os issue is in Mesa 9.0 but not in 8.0.4,
thus I fetched the Debian source package and recompiled with the fix
applied, but it did not help in my case.
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8890c759513597903997f519c69e9db30790b6f4
Because issue 48375 talked about loops and functions I tried
to manually inline all functions, but to no avail. In a second
attempt I tried to unroll the loop manually which works.
Attached is a (stripped-down) Python-OpenGL script and fragment shader
which demonstrates the issue. The shader code is taken from
http://www.codeproject.com/Articles/236394/Bi-Cubic-and-Bi-Linear-Interpolation-with-GLSL
(shader coding style ugliness is from the original source)
The script doesn't do anything useful, in the ideal case it
would just print "now" and "end" without throwing an error.
BTW, the compile error is thrown at glutSwapBuffers() not at
glCompileShaderARB() time. Is there a way to force the error
to show up earlier?
Is that the current state of affairs that using loops in GLSL is
basically broken on Intel? Any hope to get it fixed?
Thanks
Johannes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mesabug.py
Type: text/x-python
Size: 2031 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20121010/301ef325/attachment-0001.py>
-------------- next part --------------
uniform sampler2D ImageTexture;
uniform float fWidth;
uniform float fHeight;
float CatMullRom( float x )
{
float B = 0.0;
float C = 0.5;
float f = x;
if( f < 0.0 )
{
f = -f;
}
if( f < 1.0 )
{
return ( ( 12.0 - 9.0 * B - 6.0 * C ) * ( f * f * f ) +
( -18.0f + 12.0f * B + 6.0f * C ) * ( f * f ) +
( 6.0f - 2.0f * B ) ) / 6.0f;
}
else if( f >= 1.0 && f < 2.0 )
{
return ( ( -B - 6.0 * C ) * ( f * f * f )
+ ( 6.0 * B + 30.0 * C ) * ( f *f ) +
( - ( 12.0 * B ) - 48.0 * C ) * f +
8.0 * B + 24.0 * C)/ 6.0;
}
else
{
return 0.0;
}
}
vec4 BiCubic( sampler2D textureSampler, vec2 TexCoord )
{
float texelSizeX = 1.0 / fWidth; //size of one texel
float texelSizeY = 1.0 / fHeight; //size of one texel
vec4 nSum = vec4( 0.0, 0.0, 0.0, 0.0 );
vec4 nDenom = vec4( 0.0, 0.0, 0.0, 0.0 );
float a = fract( TexCoord.x * fWidth ); // get the decimal part
float b = fract( TexCoord.y * fHeight ); // get the decimal part
int nX = int(TexCoord.x * fWidth);
int nY = int(TexCoord.y * fHeight);
vec2 TexCoord1 = vec2( float(nX) / fWidth + 0.5 / fWidth,
float(nY) / fHeight + 0.5 / fHeight );
for( int m = -1; m <=2; m++ )
{
for( int n =-1; n<= 2; n++)
{
vec4 vecData = texture2D(textureSampler, TexCoord1 + vec2(texelSizeX * float( m ), texelSizeY * float( n )));
float f = CatMullRom( float( m ) - a );
vec4 vecCooef1 = vec4( f,f,f,f );
float f1 = CatMullRom( -( float( n ) - b ) );
vec4 vecCoeef2 = vec4( f1, f1, f1, f1 );
nSum = nSum + ( vecData * vecCoeef2 * vecCooef1 );
nDenom = nDenom + (( vecCoeef2 * vecCooef1 ));
}
}
return nSum / nDenom;
}
// Shader for interpolating Bi cubic in CatMull Rom method.
void main()
{
vec4 Data = BiCubic( ImageTexture, gl_TexCoord[0].st );
gl_FragColor = Data;
;
}
-------------- next part --------------
uniform sampler2D ImageTexture;
uniform float fWidth;
uniform float fHeight;
// Shader for interpolating Bi cubic in CatMull Rom method.
void main()
{
float texelSizeX = 1.0 / fWidth; //size of one texel
float texelSizeY = 1.0 / fHeight; //size of one texel
vec4 nSum = vec4( 0.0, 0.0, 0.0, 0.0 );
vec4 nDenom = vec4( 0.0, 0.0, 0.0, 0.0 );
float a = fract( gl_TexCoord[0].st.x * fWidth ); // get the decimal part
float b = fract( gl_TexCoord[0].st.y * fHeight ); // get the decimal part
float f;
int nX = int(gl_TexCoord[0].st.x * fWidth);
int nY = int(gl_TexCoord[0].st.y * fHeight);
vec2 TexCoord1 = vec2( float(nX) / fWidth + 0.5 / fWidth,
float(nY) / fHeight + 0.5 / fHeight );
for( int m = -1; m <=2; m++ )
{
for( int n =-1; n<= 2; n++)
{
vec4 vecData = texture2D(ImageTexture, TexCoord1 + vec2(texelSizeX * float( m ), texelSizeY * float( n )));
f = float(m) - a;
if (f < 0.0)
f = -f;
if (f < 1.0)
f = (9.0 * f * f * f - 15.0 * f * f + 6.0) / 6.0;
else if (f < 2.0)
f = (-3.0 * f * f * f + 15.0 * f * f - 24.0 * f + 12.0) / 6.0;
else
f = 0.0;
vec4 vecCooef1 = vec4( f,f,f,f );
f = float(n) - b;
if (f < 0.0)
f = -f;
if (f < 1.0)
f = (9.0 * f * f * f - 15.0 * f * f + 6.0) / 6.0;
else if (f < 2.0)
f = (-3.0 * f * f * f + 15.0 * f * f - 24.0 * f + 12.0) / 6.0;
else
f = 0.0;
vec4 vecCoeef2 = vec4( f, f, f, f );
nSum = nSum + ( vecData * vecCoeef2 * vecCooef1 );
nDenom = nDenom + (( vecCoeef2 * vecCooef1 ));
}
}
gl_FragColor = nSum / nDenom;
}
-------------- next part --------------
uniform sampler2D ImageTexture;
uniform float fWidth;
uniform float fHeight;
float CatMullRom(float f)
{
if (f < 0.0)
f = -f;
if (f < 1.0)
return (9.0 * f * f * f - 15.0 * f * f + 6.0) / 6.0;
else if (f < 2.0)
return (-3.0 * f * f * f + 15.0 * f * f - 24.0 * f + 12.0) / 6.0;
return 0.0;
}
vec4 BiCubic( sampler2D textureSampler, vec2 TexCoord )
{
float texelSizeX = 1.0 / fWidth; //size of one texel
float texelSizeY = 1.0 / fHeight; //size of one texel
vec4 nSum = vec4( 0.0, 0.0, 0.0, 0.0 );
vec4 nDenom = vec4( 0.0, 0.0, 0.0, 0.0 );
float a = fract( TexCoord.x * fWidth ); // get the decimal part
float b = fract( TexCoord.y * fHeight ); // get the decimal part
int nX = int(TexCoord.x * fWidth);
int nY = int(TexCoord.y * fHeight);
vec2 TexCoord1 = vec2( float(nX) / fWidth + 0.5 / fWidth,
float(nY) / fHeight + 0.5 / fHeight );
vec4 vecData, vecCoef1, vecCoef2;
float f;
float m, n;
m = -1.0; n = -1.0;
vecData = texture2D(textureSampler, TexCoord1 + vec2(texelSizeX * m, texelSizeY * n));
f = CatMullRom(m - a);
vecCoef1 = vec4(f, f, f, f);
f = CatMullRom(-(n - b));
vecCoef2 = vec4(f, f, f, f);
nSum = nSum + vecData * vecCoef2 * vecCoef1;
nDenom = nDenom + vecCoef2 * vecCoef1;
m = -1.0; n = 0.0;
vecData = texture2D(textureSampler, TexCoord1 + vec2(texelSizeX * m, texelSizeY * n));
f = CatMullRom(m - a);
vecCoef1 = vec4(f, f, f, f);
f = CatMullRom(-(n - b));
vecCoef2 = vec4(f, f, f, f);
nSum = nSum + vecData * vecCoef2 * vecCoef1;
nDenom = nDenom + vecCoef2 * vecCoef1;
m = -1.0; n = 1.0;
vecData = texture2D(textureSampler, TexCoord1 + vec2(texelSizeX * m, texelSizeY * n));
f = CatMullRom(m - a);
vecCoef1 = vec4(f, f, f, f);
f = CatMullRom(-(n - b));
vecCoef2 = vec4(f, f, f, f);
nSum = nSum + vecData * vecCoef2 * vecCoef1;
nDenom = nDenom + vecCoef2 * vecCoef1;
m = -1.0; n = 2.0;
vecData = texture2D(textureSampler, TexCoord1 + vec2(texelSizeX * m, texelSizeY * n));
f = CatMullRom(m - a);
vecCoef1 = vec4(f, f, f, f);
f = CatMullRom(-(n - b));
vecCoef2 = vec4(f, f, f, f);
nSum = nSum + vecData * vecCoef2 * vecCoef1;
nDenom = nDenom + vecCoef2 * vecCoef1;
m = 0.0; n = -1.0;
vecData = texture2D(textureSampler, TexCoord1 + vec2(texelSizeX * m, texelSizeY * n));
f = CatMullRom(m - a);
vecCoef1 = vec4(f, f, f, f);
f = CatMullRom(-(n - b));
vecCoef2 = vec4(f, f, f, f);
nSum = nSum + vecData * vecCoef2 * vecCoef1;
nDenom = nDenom + vecCoef2 * vecCoef1;
m = 0.0; n = 0.0;
vecData = texture2D(textureSampler, TexCoord1 + vec2(texelSizeX * m, texelSizeY * n));
f = CatMullRom(m - a);
vecCoef1 = vec4(f, f, f, f);
f = CatMullRom(-(n - b));
vecCoef2 = vec4(f, f, f, f);
nSum = nSum + vecData * vecCoef2 * vecCoef1;
nDenom = nDenom + vecCoef2 * vecCoef1;
m = 0.0; n = 1.0;
vecData = texture2D(textureSampler, TexCoord1 + vec2(texelSizeX * m, texelSizeY * n));
f = CatMullRom(m - a);
vecCoef1 = vec4(f, f, f, f);
f = CatMullRom(-(n - b));
vecCoef2 = vec4(f, f, f, f);
nSum = nSum + vecData * vecCoef2 * vecCoef1;
nDenom = nDenom + vecCoef2 * vecCoef1;
m = 0.0; n = 2.0;
vecData = texture2D(textureSampler, TexCoord1 + vec2(texelSizeX * m, texelSizeY * n));
f = CatMullRom(m - a);
vecCoef1 = vec4(f, f, f, f);
f = CatMullRom(-(n - b));
vecCoef2 = vec4(f, f, f, f);
nSum = nSum + vecData * vecCoef2 * vecCoef1;
nDenom = nDenom + vecCoef2 * vecCoef1;
m = 1.0; n = -1.0;
vecData = texture2D(textureSampler, TexCoord1 + vec2(texelSizeX * m, texelSizeY * n));
f = CatMullRom(m - a);
vecCoef1 = vec4(f, f, f, f);
f = CatMullRom(-(n - b));
vecCoef2 = vec4(f, f, f, f);
nSum = nSum + vecData * vecCoef2 * vecCoef1;
nDenom = nDenom + vecCoef2 * vecCoef1;
m = 1.0; n = 0.0;
vecData = texture2D(textureSampler, TexCoord1 + vec2(texelSizeX * m, texelSizeY * n));
f = CatMullRom(m - a);
vecCoef1 = vec4(f, f, f, f);
f = CatMullRom(-(n - b));
vecCoef2 = vec4(f, f, f, f);
nSum = nSum + vecData * vecCoef2 * vecCoef1;
nDenom = nDenom + vecCoef2 * vecCoef1;
m = 1.0; n = 1.0;
vecData = texture2D(textureSampler, TexCoord1 + vec2(texelSizeX * m, texelSizeY * n));
f = CatMullRom(m - a);
vecCoef1 = vec4(f, f, f, f);
f = CatMullRom(-(n - b));
vecCoef2 = vec4(f, f, f, f);
nSum = nSum + vecData * vecCoef2 * vecCoef1;
nDenom = nDenom + vecCoef2 * vecCoef1;
m = 1.0; n = 2.0;
vecData = texture2D(textureSampler, TexCoord1 + vec2(texelSizeX * m, texelSizeY * n));
f = CatMullRom(m - a);
vecCoef1 = vec4(f, f, f, f);
f = CatMullRom(-(n - b));
vecCoef2 = vec4(f, f, f, f);
nSum = nSum + vecData * vecCoef2 * vecCoef1;
nDenom = nDenom + vecCoef2 * vecCoef1;
m = 2.0; n = -1.0;
vecData = texture2D(textureSampler, TexCoord1 + vec2(texelSizeX * m, texelSizeY * n));
f = CatMullRom(m - a);
vecCoef1 = vec4(f, f, f, f);
f = CatMullRom(-(n - b));
vecCoef2 = vec4(f, f, f, f);
nSum = nSum + vecData * vecCoef2 * vecCoef1;
nDenom = nDenom + vecCoef2 * vecCoef1;
m = 2.0; n = 0.0;
vecData = texture2D(textureSampler, TexCoord1 + vec2(texelSizeX * m, texelSizeY * n));
f = CatMullRom(m - a);
vecCoef1 = vec4(f, f, f, f);
f = CatMullRom(-(n - b));
vecCoef2 = vec4(f, f, f, f);
nSum = nSum + vecData * vecCoef2 * vecCoef1;
nDenom = nDenom + vecCoef2 * vecCoef1;
m = 2.0; n = 1.0;
vecData = texture2D(textureSampler, TexCoord1 + vec2(texelSizeX * m, texelSizeY * n));
f = CatMullRom(m - a);
vecCoef1 = vec4(f, f, f, f);
f = CatMullRom(-(n - b));
vecCoef2 = vec4(f, f, f, f);
nSum = nSum + vecData * vecCoef2 * vecCoef1;
nDenom = nDenom + vecCoef2 * vecCoef1;
m = 2.0; n = 2.0;
vecData = texture2D(textureSampler, TexCoord1 + vec2(texelSizeX * m, texelSizeY * n));
f = CatMullRom(m - a);
vecCoef1 = vec4(f, f, f, f);
f = CatMullRom(-(n - b));
vecCoef2 = vec4(f, f, f, f);
nSum = nSum + vecData * vecCoef2 * vecCoef1;
nDenom = nDenom + vecCoef2 * vecCoef1;
return nSum / nDenom;
}
// Shader for interpolating Bi cubic in CatMull Rom method.
void main()
{
vec4 Data = BiCubic( ImageTexture, gl_TexCoord[0].st );
gl_FragColor = Data;
;
}
More information about the mesa-dev
mailing list