gpt4 book ai didi

c++ - Multisample framebuffer 仅与 renderbuffer 不完整

转载 作者:太空宇宙 更新时间:2023-11-04 13:19:43 26 4
gpt4 key购买 nike

我正在设置一个具有 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);

“状态”是 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);

关于c++ - Multisample framebuffer 仅与 renderbuffer 不完整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35735619/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com