Show / Hide Table of Contents

Shader Resource Mapping Table

When authoring shader code, you need to keep in mind the types of resources you define. When building a ResourceLayoutDescription, the type of each element needs to match what you have defined in your shader code. The table below maps each supported ResourceKind in Veldrid to the corresponding type of resource in each shading language.

ResourceKind GLSL Type HLSL Type MSL Type
UniformBuffer uniform block cbuffer constant T& variable
StructuredBufferReadOnly readonly buffer block StructuredBuffer/ByteAddressBuffer* device T* variable
StructuredBufferReadWrite buffer block RWStructuredBuffer/RWByteAddressBuffer* device T* variable
TextureReadOnly sampler(2D,3D) (OpenGL), texture(2D,3D) (Vulkan) Texture(2D,3D) texture(2d,3d) with with access::sample or access::read
TextureReadWrite image(2D,3D) RWTexture(2D,3D) texture(2d,3d) with access::read_write
Sampler sampler (Vulkan), Not supported in OpenGL, see Shaders SamplerState sampler
  • (RW)ByteAddressBuffer can only be used with a DeviceBuffer that was created with BufferDescription.RawBuffer set to true.
  • Improve this Doc
Back to top