Aqoole_Hateenaの技術日記

vulkan+raytraceで色々描いてます

Render Pass, SubpassとFramebufferについて

Render Passについて

仕様書には次のように書かれている。
Vulkan® 1.2.202 - A Specification (with all registered Vulkan extensions)


Draw commands must be recorded within a render pass instance. Each render pass instance defines a set of image resources, referred to as attachments, used during rendering.

描画コマンドはrender passに対して発行されるということなので、逆にrender passは描画コマンドを受け取る存在。
また一連のimage resourceを定義するともあるので、扱われるimage resourceはrender passに通知されなければならない。

Samsungの非常に有用な記事を見つけた。
https://www.khronos.org/assets/uploads/developers/library/2016-vulkan-devday-uk/6-Vulkan-subpasses.pdf
ここの23スライド目に

  • A render pass groups dependent operations
    • All images written in a render pass are the same size
  • A render pass contains a number of subpasses
    • Subpasses describe access to attachments
    • Dependencies can be defined between subpasses

という記述がある。
やはり上記と同じように、render passは一連のimage resourceを定義し、描画コマンドなどのrendering operationを受け取る存在。
またsubpassとは、color attachmentやinput attachmentなどのattachmentにアクセスするもの。

また、以下のVulkan TutorialページのQAの中にも、勉強になるコメントがある。
https://vulkan-tutorial.com/Drawing_a_triangle/Graphics_pipeline_basics/Render_passes


A graphics pipeline describes a set of operations that usually take vertices from an input buffer and ultimately write pixels to an output framebuffer. This task of writing pixels to one or more framebuffers constitutes a single sub pass. The sub pass describes which framebuffers will be accessed (read/written) by the graphics pipeline and in which state they should be at various stages in the pipeline (e.g. they should be writable right before the fragment shader starts running). It is possible that this is all of your rendering and then you can wrap this single sub pass into a render pass and call it a day, like we do in this tutorial.

結局、グラフィクスパイプラインはframebufferにピクセルを出力する。framebufferへの書き込みはsingle subpassによる。subpassはどのframebufferに出力するかの特定とどのstateにいるかの特定を行うと書かれている。
ここで言うところのframebufferが上記Samsung記事のattachmentに対応する言葉として用いられている。

Subpassについて

  • A render pass contains a number of subpasses
    • Subpasses describe access to attachments
    • Dependencies can be defined between subpasses

https://www.khronos.org/assets/uploads/developers/library/2016-vulkan-devday-uk/6-Vulkan-subpasses.pdf


A subpass represents a phase of rendering that reads
and writes a subset of the attachments in a render pass.
Rendering commands are recorded into a particular
subpass of a render pass instance.

https://www.khronos.org/assets/uploads/developers/library/2018-vulkan-devday/02-RenderPass-Subpass.pdf
Subpassはrender passでのattachmentにアクセスする処理の段階を表す。

Framebufferについて

一言で言えば、frame bufferとはrender passのためのbuffer。
仕様書には
Vulkan® 1.2.202 - A Specification (with all registered Vulkan extensions)


Render passes operate in conjunction with framebuffers. Framebuffers represent a collection of specific memory attachments that a render pass instance uses.

Render PassはFramebuffers連動して動作し、framebuffersはrender passが用いるmemory attachments(color image bufferやdepth bufferなど)の集合を表すとある。
参考:https://vulkan.lunarg.com/doc/view/1.2.154.1/windows/tutorial/html/12-init_frame_buffers.html


Vulkan Tutorialのページにも以下のように、framebufferはattachmentであるVkImageViewを表すとある。
Framebuffers - Vulkan Tutorial


A framebuffer object references all of the VkImageView objects that represent the attachments.

更新履歴

2022/1/5 「Framebufferについて」の内容を修正