【发布时间】:2020-02-21 05:48:40
【问题描述】:
这是我目前的设置:
- 开始渲染通道
- 着色器 1 将颜色输出到 5 个附件。
- 着色器 2 将颜色输出到相同的 5 个附件
- 完成录制命令
然而,第二个并不真正需要输出任何东西到 5 个附件,只需要输出到第一个。
是否可以即时更改附件数量?比如:
- 开始渲染通道
- 着色器 1 将颜色输出到 5 个附件。
- 在渲染过程中修改活动帧缓冲区
- 着色器 2 仅将颜色输出到第一个附件中的一个。
- 完成录制命令
或者,如果那无法完成。是否可以关闭渲染通道之间的附件清除?
编辑有问题的片段着色器如下所示:
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) out vec4 color_out;
layout(location = 1) out vec4 color_out1;
layout(location = 2) out vec4 color_out2;
layout(location = 3) out vec4 color_out3;
layout(location = 4) out vec4 color_out4;
void main()
{
color_out = vec4(1,1,1,1);
color_out1 = vec4(0,0,0,0);
color_out2 = vec4(0,0,0,0);
color_out3 = vec4(0,0,0,0);
color_out4 = vec4(0,0,0,0);
}
我正在努力摆脱它。
我目前的渲染方式是:
// Initialize the FB with 5 image attachemnts + the clear values, etc...
vk::RenderPassBeginInfo render_pass_info;
render_pass_info.renderPass = *render_pass;
render_pass_info.framebuffer = *framebuffer;
render_pass_info.renderArea = vk::Rect2D({0,0}, extent);
render_pass_info.clearValueCount = clears.size();
render_pass_info.pClearValues = clears.data();
cmd.beginRenderPass(&render_pass_info, vk::SubpassContents::eInline);
/* setup pipeline 1 info, like it's descriptor sets, samplers etc*/
cmd.bindPipeline(vk::PipelineBindPoint::eGraphics, *graphics_pipeline);
cmd.bindDescriptorSets(vk::PipelineBindPoint::eGraphics, *pipeline_layout, 0, 1, descriptor_set_ptr, 0, nullptr);
/* Do the same for the second pipeline */
cmd.bindPipeline(vk::PipelineBindPoint::eGraphics, *graphics_pipeline);
cmd.bindDescriptorSets(vk::PipelineBindPoint::eGraphics, *pipeline_layout, 0, 1, descriptor_set_ptr, 0, nullptr);
目标是不在着色器中输出额外的 5 个附件。当前终止我的程序并出现以下错误:
Message ID name: UNASSIGNED-CoreValidation-Shader-InputNotProduced
Message: Attachment 1 not written by fragment shader; undefined values will be written to attachment
Severity: VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT
【问题讨论】:
-
您有 2 个子通行证,对吗?从这个问题中,我了解到第一个子通道会写入 5 个附件,而第二个子通道不会写入其中任何一个。
-
@NicolBolas 它正在输出颜色到一个附件,然后没有输出到另一个 4。我写的时候出错了,谢谢你的注意。
-
@NishantSingh 相反,第二个子通道应该只写入一个附件。
标签: c++ graphics rendering vulkan