How to use sampler on inputattachment

Hi,i have a shader using two renderpass, the output of pass1 should be used as the input of pass2. And i want to optimize it using subpass.

I have to question:

1.Just like the simplified code below, input is no longer of texture type and I will not be able to use sampler on input. What is the usual solution at this time?

//  pass2:
layout(set = 0, binding = 0) uniform texture2D input;
// =>
// layout(input_attachment_index = 0, set = 0, binding = 0) uniform subpassInput input;
layout(set = 0, binding = 1) uniform sampler s;
void main()
{
    sampler2D(input, s);
    return;
}

2. Another question from a beginner:
In this example. After updating an image view descriptor to the attachment, I think the underlying type of the attachment seems to be texture2D. Why are such grammar rules not allowed? The input_attachment_index keyword guides the API to optimize resources between subpasses. And texture2D does not change its underlying type.

layout(input_attachment_index = 0, set = 0, binding = 0) uniform texture2D input;

The only thing you can do with a subpass input attachment is read from the texel that your fragment covers. As such, samplers don’t make sense (as they can read from other texels); you have to use subpassLoad to access subpass input attachments.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.