我将此sample移植到来自g-truc的jogl并且它可以正常工作,一切都很好。
但现在我想确切了解stream
glDrawTransformFeedbackStream
所指的内容。
基本上vec4 position
输入转换为
String[] strings = {"gl_Position", "Block.color"};
gl4.glTransformFeedbackVaryings(transformProgramName, 2, strings, GL_INTERLEAVED_ATTRIBS);
如下:
void main()
{
gl_Position = mvp * position;
outBlock.color = vec4(clamp(vec2(position), 0.0, 1.0), 0.0, 1.0);
}
transform-stream.vert,transform-stream.geom
然后我只使用glDrawTransformFeedbackStream
feedback-stream.vert,feedback-stream.frag
现在,他们根据docs说:
指定转换反馈流的索引 检索原始计数。
很酷,所以如果我将feedbackArrayBufferName
绑定到0
here
gl4.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, feedbackName[0]);
gl4.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, feedbackArrayBufferName[0]);
gl4.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
我想应该是这样。
几何着色器outputs(仅)用于索引0的颜色。位置怎么样?他们假设已经在0流?怎么样?来自glTransformFeedbackVaryings
?
因此,我尝试将对此流的所有引用切换为1,以检查它们是否一致,然后是否引用相同的索引。
所以我修改了
gl4.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 1, feedbackArrayBufferName[0]);
和
gl4.glDrawTransformFeedbackStream(GL_TRIANGLES, feedbackName[0], 1);
以及几何着色器内部
out Block
{
layout(stream = 1) vec4 color;
} outBlock;
但如果我跑,我得到:
Program link failed: 1
Link info
---------
error: Transform feedback can't capture varyings belonging to different vertex streams in a single buffer.
OpenGL Error(GL_INVALID_OPERATION): initProgram
GlDebugOutput.messageSent(): GLDebugEvent[ id 0x502
type Error
severity High: dangerous undefined behavior
source GL API
msg GL_INVALID_OPERATION error generated. <program> object is not successfully linked, or is not a program object.
when 1455183474230
source 4.5 (Core profile, arb, debug, compat[ES2, ES3, ES31, ES32], FBO, hardware) - 4.5.0 NVIDIA 361.43 - hash 0x225c78a9]
GlDebugOutput.messageSent(): GLDebugEvent[ id 0x502
type Error
severity High: dangerous undefined behavior
source GL API
msg GL_INVALID_OPERATION error generated. <program> has not been linked, or is not a program object.
when 1455183474232
source 4.5 (Core profile, arb, debug, compat[ES2, ES3, ES31, ES32], FBO, hardware) - 4.5.0 NVIDIA 361.43 - hash 0x225c78a9]
试着知道发生了什么,我发现了here
Output variables in the Geometry Shader can be declared to go to a particular stream. This is controlled via an in-shader specification, but there are certain limitations that affect advanced component interleaving.
No two outputs that go to different streams can be captured by the same buffer. Attempting to do so will result in a linker error. So using multiple streams with interleaved writing requires using advanced interleaving to route attributes to different buffers.
这是怎么回事? position
将索引为0并将颜色设置为索引1?
我只想知道我的假设是否正确。如果是,我想通过更改流索引来证明它。
因此,我还想知道在更改后我如何在流1上设置position
和颜色。我应该以这种方式修改几何着色器的输出layout(triangle_strip, max_vertices = 3, xfb_buffer = 1) out;
吗?
因为它抱怨
Shader status invalid: 0(11) : error C7548: 'layout(xfb_buffer)' requires "#extension GL_ARB_enhanced_layouts : enable" before use
然后我添加它,我得到了
error: Transform feedback can't capture varyings belonging to different vertex streams in a single buffer.
但现在他们应该在第一流,我缺少什么?
此外,流的定义是什么?