'Can different size images be attached to a framebuffer?
I've decided I'm going to include a R32_UINT picking buffer among all the other buffers written in the render pass, even if the shader will not write to it. So I might have:
attachment 0 = colour;
attachment 1 = picking(int);
attachment 2 = normals;
My question is, say I'm rendering to a 800 x 600 framebuffer, I attach 800 x 600 images to this framebuffer. However since I won't be doing picking in this pass I want to attach a dummy image to attachment 1, and the shader simply won't write to it. This dummy image will probably be as small as possible, so just a few pixels, even though the framebuffer will be 800 x 600, and so too will be the other images.
Then I switch the framebuffer and either switch the pipeline, or set a bool in a uniform to write into the picking buffer. When I bind this framebuffer I want to bind an image of the appropriate size at attachment 1 and now instead have attachments 0 and 2 have dummy images (again small sizes, maybe a couple of pixels or a 1x1 pixel). Or preferably is there a way to not even attach dummies?
Is this a viable way to do it? The reason I want to do this is to avoid doubling each shader that's written for a picking version, it becomes extremely unwieldy and this is a much cleaner solution IMO. I can make conditional branch in the shader over a specialization constant so performance won't suffer.
Solution 1:[1]
Every VkFramebuffer object is created with a width that must be less than or equal to the width of all image subresources used by the framebuffer. That is, it must be smaller than or equal to the smallest width (the same goes for height). When beginning a render pass, the renderArea you provide must specify an area within the VkFramebuffer's area.
So if you put a small image in with the rest, the rendering area must be no larger than that image's size.
Note that the same applies for dynamic rendering (ie: rendering without a render pass or VkFramebuffer).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nicol Bolas |
