Ok, so I'm mad with this error which just doesn't make sense to me. I ended up creating the following minimal example:
shaders:
vertex
#version 420
#define N 6 // 6 or more = bug
layout(location=0) in vec3 v[N];
out vec3 n[4];
void main()
{
vec3 v0 = v[0];
for (int i = 0; i < N - 2; i++) n[i] = normalize(cross(v[i + 1] - v0, v[i + 2] - v0));
//n[0] = normalize(cross(v[1] - v0, v[2] - v0));//stupid driver bug can't unroll loops???
//n[1] = normalize(cross(v[2] - v0, v[3] - v0));
//n[2] = normalize(cross(v[3] - v0, v[4] - v0));
//n[3] = normalize(cross(v[4] - v0, v[5] - v0));
}
fragment
void main()
{
}
I get a linking error:
Internal error: assembly compile error for vertex shader at offset 586:
-- error message --
line 20, column 59: error: offset for relative array access outside supported range
line 21, column 40: error: offset for relative array access outside supported range
-- internal assembly text --
!!NVvp5.0
OPTION NV_internal;
OPTION NV_bindless_texture;
# cgc version 3.4.0001, build date Aug 5 2021
# command line args:
#vendor NVIDIA Corporation
#version 3.4.0.1 COP Build Date Aug 5 2021
#profile gp5vp
#program main
#var float3 v[0] : $vin.ATTR0 : ATTR0 : -1 : 1
#var float3 n[0] : $vout.ATTR0 : ATTR0 : -1 : 1
ATTRIB vertex_attrib[] = { vertex.attrib[0..5] };
OUTPUT result_attrib[] = { result.attrib[0..3] };
SHORT TEMP H0;
TEMP R0, R1, R2;
TEMP T;
MOV.S R0.w, {0, 0, 0, 0}.x;
REP.S {4, 0, 0, 0};
MOV.S R0.x, R0.w;
ADD.F32 R1.xyz, -vertex.attrib[0], vertex_attrib[R0.x + 32];
ADD.F32 R0.xyz, vertex_attrib[R0.x + 16], -vertex.attrib[0];
MUL.F32 R2.xyz, R0.zxyw, R1.yzxw;
MAD.F32 R0.xyz, R0.yzxw, R1.zxyw, -R2;
DP3.F32 R1.x, R0, R0;
RSQ.F32 R1.x, R1.x;
MUL.F32 R0.xyz, R1.x, R0;
MOV.S R1.x, R0.w;
MOV.F result_attrib[R1.x].xyz, R0;
ADD.S R0.w, R0, {1, 0, 0, 0}.x;
ENDREP;
END
# 14 instructions, 3 R-regs
If I manually unroll the loops, it seems to work. I never faced such a weird bug. What's going on here? Can someone test on AMD?