Multisample framebuffer 仅与 renderbuffer 不完整
Multisample framebuffer only incomplete with renderbuffer
我正在设置一个带有 4 个颜色附件和 1 个深度模板附件的多重采样帧缓冲区。目前 GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 不完整。如果我不附加渲染缓冲区,它就可以完美运行。调试输出未打印任何内容,glGetError() 未显示任何问题。
GLint samples;
glGetIntegerv(GL_MAX_SAMPLES, &samples);
const GLuint target = GL_TEXTURE_2D_MULTISAMPLE;
const GLenum format[TEXTURES_PER_FBO] = {
GL_RGBA32F, GL_RGB32F, GL_RGB32F, GL_R8UI // TODO tune these
};
// create render textures
glGenTextures(NUM_TEXTURES, textures);
for (int i = 0; i < NUM_TEXTURES; i++) {
glActiveTexture(GL_TEXTURE0 + i);
glBindTexture(target, textures[i]);
const int index = i % TEXTURES_PER_FBO;
glTexStorage2DMultisample(target, samples, format[index], width, height, false);
}
glGenRenderbuffers(1, &depth);
glBindRenderbuffer(GL_RENDERBUFFER, depth);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, GL_DEPTH24_STENCIL8, width, height);
// create first framebuffer with depth attachment
glGenFramebuffers(NUM_FBOS, fbos);
glBindFramebuffer(GL_FRAMEBUFFER, fbos[0]);
for (int i = 0; i < TEXTURES_PER_FBO; i++) {
const GLenum index = GL_COLOR_ATTACHMENT0 + i;
glFramebufferTexture2D(GL_FRAMEBUFFER, index, target, textures[i], 0);
}
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depth);
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
'status' 是 GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE
我已经在 windows 上的 gtx 980 和 480 上进行了测试。我目前无法访问其他人,但如果未解决,我会尝试获取一些。
如果您需要更多上下文代码,可以找到 here
谢谢!
如果您还有渲染缓冲区附件,则需要为 glTexStorage2DMultisample()
的 fixedsamplelocations(最后一个)参数传递 GL_TRUE
。否则你会得到你观察到的 GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE
错误。
来自规范中可能的 glCheckFramebufferStatus()
结果列表(例如 OpenGL 4.5 规范的第 311 页,“9.4.2 整体帧缓冲区完整性”部分):
The value of TEXTURE_FIXED_SAMPLE_LOCATIONS is the same for all attached textures; and, if the attached images are a mix of renderbuffers and textures, the value of TEXTURE_FIXED_SAMPLE_LOCATIONS must be TRUE for all attached textures. {FRAMEBUFFER_INCOMPLETE_MULTISAMPLE}
因此您需要更改对此的调用以获得有效的 FBO 配置:
glTexStorage2DMultisample(target, samples, format[index], width, height, GL_TRUE);
我正在设置一个带有 4 个颜色附件和 1 个深度模板附件的多重采样帧缓冲区。目前 GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 不完整。如果我不附加渲染缓冲区,它就可以完美运行。调试输出未打印任何内容,glGetError() 未显示任何问题。
GLint samples;
glGetIntegerv(GL_MAX_SAMPLES, &samples);
const GLuint target = GL_TEXTURE_2D_MULTISAMPLE;
const GLenum format[TEXTURES_PER_FBO] = {
GL_RGBA32F, GL_RGB32F, GL_RGB32F, GL_R8UI // TODO tune these
};
// create render textures
glGenTextures(NUM_TEXTURES, textures);
for (int i = 0; i < NUM_TEXTURES; i++) {
glActiveTexture(GL_TEXTURE0 + i);
glBindTexture(target, textures[i]);
const int index = i % TEXTURES_PER_FBO;
glTexStorage2DMultisample(target, samples, format[index], width, height, false);
}
glGenRenderbuffers(1, &depth);
glBindRenderbuffer(GL_RENDERBUFFER, depth);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, GL_DEPTH24_STENCIL8, width, height);
// create first framebuffer with depth attachment
glGenFramebuffers(NUM_FBOS, fbos);
glBindFramebuffer(GL_FRAMEBUFFER, fbos[0]);
for (int i = 0; i < TEXTURES_PER_FBO; i++) {
const GLenum index = GL_COLOR_ATTACHMENT0 + i;
glFramebufferTexture2D(GL_FRAMEBUFFER, index, target, textures[i], 0);
}
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depth);
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
'status' 是 GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE
我已经在 windows 上的 gtx 980 和 480 上进行了测试。我目前无法访问其他人,但如果未解决,我会尝试获取一些。 如果您需要更多上下文代码,可以找到 here 谢谢!
如果您还有渲染缓冲区附件,则需要为 glTexStorage2DMultisample()
的 fixedsamplelocations(最后一个)参数传递 GL_TRUE
。否则你会得到你观察到的 GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE
错误。
来自规范中可能的 glCheckFramebufferStatus()
结果列表(例如 OpenGL 4.5 规范的第 311 页,“9.4.2 整体帧缓冲区完整性”部分):
The value of TEXTURE_FIXED_SAMPLE_LOCATIONS is the same for all attached textures; and, if the attached images are a mix of renderbuffers and textures, the value of TEXTURE_FIXED_SAMPLE_LOCATIONS must be TRUE for all attached textures. {FRAMEBUFFER_INCOMPLETE_MULTISAMPLE}
因此您需要更改对此的调用以获得有效的 FBO 配置:
glTexStorage2DMultisample(target, samples, format[index], width, height, GL_TRUE);