Skip to content

Renderer Resources

harrand edited this page Jul 11, 2023 · 2 revisions

Resource Type

Resources can be one of two types.

Buffer resources typically are used to populate chunks of binary data. Buffers are comprised of:

  • A size, in bytes
  • An array (of the aforementioned size) containing arbitrary data.

Buffers expose this data to the shaders running on the GPU, allowing for complicated behaviour and state. However, there are other more specialised uses for buffers, which can be enabled via additional resource flags.

For example, a buffer resource could be an index buffer, meaning that its data is intended to represent an array of offsets into the vertex data, as opposed to drawing with count equal to the number of vertices. Another type of specialised buffer is a draw-indirect buffer.

Images represent 2-dimensional arrays of data, typically used to represent textures for rendered geometry.

By default images are sampled using nearest filtering (otherwise known as point sampling), and texture coordinates are clamped between [0.0-1.0], deriving the value from the texels at the edge of the image if the texture coordinate is out of this range.

All resources have an access specifier. By default, resources have an access of static_access.

Static access resources can only be written to on creation. In other words, a buffer/image resource with static access cannot have its data modified CPU-side after creation, unless a (GIVE ME A LINK LMAO - renderer edit) is performed.

Dynamic access resources expose a data span which automatically updates the underlying data store. This means you can write into this data span at any point during the resource's lifetime, and it will be resident instantaneously.

⚠️ Warning

You should take care when writing to a dynamic resource, as you may run into undefined behaviour if you do so while the resource is currently being used by a shader that is currently in-flight.

Previously on this page it was stated that both image and buffer resources have various default, but additional opt-in behaviour which can be enabled. Resource flags allow you to enable these behaviours for a specific resource. To see the list of all resource flags, click here.

ℹ️ Information

Some resources are only valid for a specific resource type. For example, it is invalid to specify tz::gl::resource_flag::index_buffer on an image resource!