Texture vs attachment

I’ve heard that an image in Vulkan can either be a texture or a framebuffer attachment.

  1. Why do you call it an “attachment”? Is it, like, attached to it like a document to an email?
  2. What is the practical difference between the two?
  1. I guess. Analogies are dangerous.

It is likely called “attachment” because of the role it plays in the Render Pass. When creating a render pass you make these “attachments” (basically placeholders), but do not provide actual Images.
Then on BeginRnderPass the attachments from Render Pass (the placeholders) and from Framebuffer (the real Images) are bound together. The Images get “attached” to the Pass… or something. Just don’t get too much distracted by informal human language semantics…

  1. VkImage is a raw memory + format (i.e. wrapper for raw memory that makes it addressable by texels instead of bytes).

Attachment is a reference to the Image in the VkFramebuffer which needs other stuff to know beside the Image (e.g. can have more images in one framebuffer). And attachment is also a placeholder for the Image in VkRenderPass.

I was also answering something like that on SO.

Then what will be a texture? An image bound via resource descriptor?

You can use an image view as a texture in a shader (attaching it to a texture* or sampler* uniform descriptor). But Vulkan doesn’t really have the concept of “texture” as a distinct object type separate from anything else.

Similarly, an image is not an attachment. You use an image as a framebuffer attachment. But that doesn’t make the image into an attachment.

Images store image data. They can be used in a number of ways.

REMOVED
NVM, ninja’d.

Ok, thank you :slight_smile:

So basically what is the difference between reading from texture or from input attachment?

So basically what is the difference between reading from texture or from input attachment?

Pretty much everything. The only things they have in common are:

  1. They both go into descriptors.

  2. They both get their data from images. Though even this is a technicality, since at the time you access an image through an input attachment, that image’s data effectively lives in the render pass memory.

They aren’t even accessed through the same types/functions in Vulkan GLSL. Input attachments use opaque types of the form subpassInput* and the subpassLoad function. Textures use different types and functions.