Aqoole_Hateenaの技術日記

vulkan+raytraceで色々描いてます

BuffersとBuffer Viewsについて

Buffersについて

仕様書によるとVulkan® 1.2.202 - A Specification (with all registered Vulkan extensions)

Vulkan supports two primary resource types: buffers and images. Resources are views of memory with associated formatting and dimensionality. Buffers are essentially unformatted arrays of bytes whereas images contain format information, can be multidimensional and may have associated metadata.

とあるので、BuffersとImagesとはresourceであることがわかる。ここでResourceとはメモリにアクセスするViewのことで、対応したフォーマットと次元数がある。Buffersは本質的には決まったフォーマットを持たないバイトの羅列で、対してImagesは定められたフォーマットをもつ。

続いて以下のようにも書かれている。

Buffers represent linear arrays of data which are used for various purposes by binding them to a graphics or compute pipeline via descriptor sets or via certain commands, or by directly specifying them as parameters to certain commands.

Buffersは線形(一次元)のデータの配列を表し、descriptor setやcommandを通してpipelineにbindされることで使用される。
descriptor setとはpipelineで用いるオブジェクトをまとめたもので、pipeline作成時にlayoutとして予め宣言しておく必要がある。

Buffer Viewsについて

仕様書によるとVulkan® 1.2.202 - A Specification (with all registered Vulkan extensions)

A buffer view represents a contiguous range of a buffer and a specific format to be used to interpret the data. Buffer views are used to enable shaders to access buffer contents interpreted as formatted data.

Buffer viewsはBufferの連続領域を表し、通信するための特定のフォーマットをもつ。Buffer Viewsはshadersが読み書きできるbufferにアクセスできるようにするとある。つまり、Bufferはbuffer viewを用いてアクセスされることにより、shaderはbufferを連続領域として扱える。