I have a effect type of setup that generates glsl shaders based on some other inputs.
The programs compile and link fine but what I am seeing is that I can only call the first function defined in the file from main and have it produce usable output.
The three functions are exactly the same(for testing this) but if i call skinnedshader2 from main as in the example below it works. If i call say skinnedshader instead it still compiles and builds, but the assembly is much shorter and running it produces no output.
I included the functions below and the IL generated from gpu shader analyzer. The only difference is changing which function main calls but both functions are identical.
If reorder functions in the file that will fix it too so now the one called from main is first.
From my inital looking at the glsl spec i can't find anything about function ordering having an effect.
I have also tried rearranging main and doing function prototypes etc. And didn't seem to make any difference.
My thoughts maybe it has something to do with the gl_ variables or something, but I didn't see anything in the spec saying they must be set at a specific place or not from multiple functions etc.
Thanks
void skinnedshader2()
{
gl_Position = uWVP * vec4(srcPosition, 1.0);
vertTexCoord = srcTexCoord.xy;
vertNormal = (uWorld * vec4(srcNormal, 0.0));
vertWPosition = (uWorld * vec4(srcPosition, 1.0));
}
void skinnedshader()
{
gl_Position = uWVP * vec4(srcPosition, 1.0);
vertTexCoord = srcTexCoord.xy;
vertNormal = (uWorld * vec4(srcNormal, 0.0));
vertWPosition = (uWorld * vec4(srcPosition, 1.0));
}
void vshader()
{
gl_Position = uWVP * vec4(srcPosition, 1.0);
vertTexCoord = srcTexCoord.xy;
vertNormal = (uWorld * vec4(srcNormal, 0.0));
vertWPosition = (uWorld * vec4(srcPosition, 1.0));
}
void main()
{
skinnedshader2();
}
IL calling skinnedshader from main
il_vs_2_0
dcl_input_generic v2
dcl_input_generic v0
dcl_input_generic v1
dcl_output_generic o0
dcl_output_generic o1
dcl_output_generic o2
dcl_literal l8, 0x3F800000, 0x00000000, 0x00000000, 0x00000000
call 1
mov o0, r9
mov o1.xy__, r5.xyyy
mov o2, r13
endmain
func 1
mov r14.xyz_, v0.xyzz
mov r15.x___, l8.x
mov r14.___w, r15.x
mul r16, r14.w, c3
mad r16, r14.z, c2, r16
mad r16, r14.y, c1, r16
mad r16, r14.x, c0, r16
mov r4, r16
mov r5.xy__, v1.xyyy
mov r17.xyz_, v2.xyzz
mov r18.x___, l8.y
mov r17.___w, r18.x
mul r19, r17.w, c7
mad r19, r17.z, c6, r19
mad r19, r17.y, c5, r19
mad r19, r17.x, c4, r19
mov r9, r19
mov r20.xyz_, v0.xyzz
mov r21.x___, l8.x
mov r20.___w, r21.x
mul r22, r20.w, c7
mad r22, r20.z, c6, r22
mad r22, r20.y, c5, r22
mad r22, r20.x, c4, r22
mov r13, r22
endfunc
end
IL calling skinnedshader2 from main
il_vs_2_0
dcl_input_generic v2
dcl_input_generic v0
dcl_input_generic v1
dcl_output_position o3
dcl_output_generic o0
dcl_output_generic o1
dcl_output_generic o2
dcl_literal l8, 0x3F800000, 0x00000000, 0x00000000, 0x00000000
call 0
mov r3500, r4
mov o0, r9
mov o1.xy__, r5.xyyy
mov o2, r13
mov o3, r3500
endmain
func 0
mov r1.xyz_, v0.xyzz
mov r2.x___, l8.x
mov r1.___w, r2.x
mul r3, r1.w, c3
mad r3, r1.z, c2, r3
mad r3, r1.y, c1, r3
mad r3, r1.x, c0, r3
mov r4, r3
mov r5.xy__, v1.xyyy
mov r6.xyz_, v2.xyzz
mov r7.x___, l8.y
mov r6.___w, r7.x
mul r8, r6.w, c7
mad r8, r6.z, c6, r8
mad r8, r6.y, c5, r8
mad r8, r6.x, c4, r8
mov r9, r8
mov r10.xyz_, v0.xyzz
mov r11.x___, l8.x
mov r10.___w, r11.x
mul r12, r10.w, c7
mad r12, r10.z, c6, r12
mad r12, r10.y, c5, r12
mad r12, r10.x, c4, r12
mov r13, r12
endfunc
end