Sign in to follow this  

GLSL varying limit

This topic is 3634 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible for a driver to claim to support more GLSL varying variables than it actually does? On my new GF8800 GTS, querying GL_MAX_VARYING_FLOATS returns 60. Despite this, exceeding 32 varying floats causes an error. For example:
//Vertex shader
const int arraysize=8;
varying vec4 foo[arraysize];
void main()
{
        for(int i=0; i<arraysize; i++) foo[i]=vec4(i,i,i,i);
	gl_Position = ftransform();
}
 
//Fragment shader
const int arraysize=8;
varying vec4 foo[arraysize];
void main()
{
        for(int i=0; i<arraysize; i++) gl_FragColor*=foo[i];
}



This compiles and links okay. However, changing the constant int arraysize to 9 (thereby raising the number of varying floats from 32 to 36) yields the linker error 'C5041: cannot locate suitable resource to bind parameter "<null atom>".' So what's going on? Why can't I exceed 32 floats? I've just upgraded from a GF5200, so perhaps I'm missing something obvious. Any help would be appreciated.

Share this post


Link to post
Share on other sites
no idea, perhaps u can look at the generated asm file (theres a small app at nvidias site that lets u enable this to be printed out)

Share this post


Link to post
Share on other sites
Uh, for some reason NVEmulate won't output the asm from the fragment shader. Here's the vertex shader, though:

!!ARBvp1.0
OPTION NV_vertex_program3;
# cgc version 1.6.0011, build date Feb 23 2007 10:43:40
# command line args:
#vendor NVIDIA Corporation
#version 1.6.0.11
#profile vp40
#program main
#semantic gl_ModelViewProjectionMatrixTranspose : STATE.MATRIX.MVP
#var float4 gl_Position : $vout.POSITION : HPOS : -1 : 1
#var float4 gl_Vertex : $vin.POSITION : ATTR0 : -1 : 1
#var float4x4 gl_ModelViewProjectionMatrixTranspose : STATE.MATRIX.MVP : c[0], 4 : -1 : 1
#var float4 foo[0] : : : -1 : 0
#var float4 foo[1] : : : -1 : 0
#var float4 foo[2] : : : -1 : 0
#var float4 foo[3] : : : -1 : 0
#var float4 foo[4] : : : -1 : 0
#var float4 foo[5] : : : -1 : 0
#var float4 foo[6] : : : -1 : 0
#var float4 foo[7] : : : -1 : 0
#var float4 foo[8] : : : -1 : 0
PARAM c[4] = { state.matrix.mvp };
TEMP RC, HC;
BB1:
DP4 result.position.w, vertex.attrib[0], c[3];
DP4 result.position.z, vertex.attrib[0], c[2];
DP4 result.position.y, vertex.attrib[0], c[1];
DP4 result.position.x, vertex.attrib[0], c[0];
END
# 4 instructions, 0 R-regs



Looks kosher to me, though what I know about assembler could be written on a gnat's eyelash. Any ideas?

Share this post


Link to post
Share on other sites
Yep, this doesn't work either:


//Vertex shader
varying vec4 foo0, foo1, foo2, foo3, foo4, foo5, foo6, foo7, foo8;
void main()
{
foo0=0;
foo1=1;
foo2=2;
foo3=3;
foo4=4;
foo5=5;
foo6=6;
foo7=7;
foo8=8;
gl_Position = ftransform();
}

//Fragment shader
varying vec4 foo0, foo1, foo2, foo3, foo4, foo5, foo6, foo7, foo8;
void main(void)
{
gl_FragColor += foo0;
gl_FragColor += foo1;
gl_FragColor += foo2;
gl_FragColor += foo3;
gl_FragColor += foo4;
gl_FragColor += foo5;
gl_FragColor += foo6;
gl_FragColor += foo7;
gl_FragColor += foo8;
}



This gives me 'error C5041: cannot locate suitable resource to bind parameter "foo8"'.

Share this post


Link to post
Share on other sites

This topic is 3634 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this