Link 错误取决于 for 循环长度
Link error dependent on for loop length
我有一个着色器程序,在几何着色器中有一个 for 循环。当 for 循环长度足够小时,程序 links(并运行)正常。如果我增加长度,则会收到 link 错误(日志为空)。着色器在这两种情况下都可以正常编译。这是几何着色器代码(包含我认为相关的所有内容):
#version 330
layout (points) in;
layout (triangle_strip, max_vertices = 256) out;
...
void main()
{
...
for(int i = 0 ; i < 22 ; ++i) // <-- Works with 22, not with 23.
{
...
EmitVertex();
...
EmitVertex();
...
EmitVertex();
...
EmitVertex();
EndPrimitive();
}
}
规格说明:"non-terminating loops are allowed. The consequences of very long or non-terminating loops are platform dependent." 这可能是平台相关情况 (GeForce GT 640)?随着着色器代码的发展,for 循环的最大长度发生了变化(更多代码 -> 更小的最大值),这让我怀疑它与循环展开有关。谁能给我更多关于这个问题的信息? (如果您需要更多,请告诉我 code/description。)
link 包含几何着色器的程序失败的一个可能原因是 GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS
限制。 OpenGL 4.5 core profile specifiaction 的第 11.3.4.5 "Geometry Shader Outputs" 节指出(我强调):
There are two implementation-dependent limits on the value of GEOMETRY_VERTICES_OUT
; it may not exceed the value of MAX_GEOMETRY_OUTPUT_VERTICES
, and the product of the total number of vertices and the sum of all
components of all active output variables may not exceed the value of MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS
. LinkProgram
will fail if it determines
that the total component limit would be violated.
GL保证这个total component limit至少是1024。
您没有粘贴着色器的完整代码,因此不清楚每个顶点使用了多少个组件,但这可能是 link 失败的原因。
If I increase the length then I get a link error (with empty log).
规范根本不需要任何 linker 或编译器消息。但是,Nvidia 通常会提供相当不错的日志消息。如果您可以在最新的驱动程序版本中重现 "link failure without log message" 场景,则可能值得提交错误报告。
我有一个着色器程序,在几何着色器中有一个 for 循环。当 for 循环长度足够小时,程序 links(并运行)正常。如果我增加长度,则会收到 link 错误(日志为空)。着色器在这两种情况下都可以正常编译。这是几何着色器代码(包含我认为相关的所有内容):
#version 330
layout (points) in;
layout (triangle_strip, max_vertices = 256) out;
...
void main()
{
...
for(int i = 0 ; i < 22 ; ++i) // <-- Works with 22, not with 23.
{
...
EmitVertex();
...
EmitVertex();
...
EmitVertex();
...
EmitVertex();
EndPrimitive();
}
}
规格说明:"non-terminating loops are allowed. The consequences of very long or non-terminating loops are platform dependent." 这可能是平台相关情况 (GeForce GT 640)?随着着色器代码的发展,for 循环的最大长度发生了变化(更多代码 -> 更小的最大值),这让我怀疑它与循环展开有关。谁能给我更多关于这个问题的信息? (如果您需要更多,请告诉我 code/description。)
link 包含几何着色器的程序失败的一个可能原因是 GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS
限制。 OpenGL 4.5 core profile specifiaction 的第 11.3.4.5 "Geometry Shader Outputs" 节指出(我强调):
There are two implementation-dependent limits on the value of
GEOMETRY_VERTICES_OUT
; it may not exceed the value ofMAX_GEOMETRY_OUTPUT_VERTICES
, and the product of the total number of vertices and the sum of all components of all active output variables may not exceed the value ofMAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS
.LinkProgram
will fail if it determines that the total component limit would be violated.
GL保证这个total component limit至少是1024。
您没有粘贴着色器的完整代码,因此不清楚每个顶点使用了多少个组件,但这可能是 link 失败的原因。
If I increase the length then I get a link error (with empty log).
规范根本不需要任何 linker 或编译器消息。但是,Nvidia 通常会提供相当不错的日志消息。如果您可以在最新的驱动程序版本中重现 "link failure without log message" 场景,则可能值得提交错误报告。