Skip to main content

GPU Resources

A key role of the Device class is to let the application create GPU resources. The main GPU resources that applications will typically be creating directly are Buffer and Texture objects.

However there is a number of other GPU resource objects. These are usually created automatically behind the scenes, e.g. by the Model and Transform classes, but can be created directly if needed.

Types of GPU Resources

GPU resources correspond to data on the GPU and/or a state object in the GPU driver.

  • Resources that represent actual memory uploaded to the GPU are Buffer and Texture.
  • Resources that hold executable GPU code, such as Shader, Renderpipeline and ComputePipeline.
  • Other GPU resources tend to hold validated settings or state (usually these are GPU driver objects rather)

Creating GPU Resources

The Device class provides methods for creating GPU resources provides a consistent API

Resource creation methodDescription
device.createBuffer(props: BufferProps)
device.createBuffer(props: ArrayBuffer)
device.createBuffer(props: ArrayBufferView)
Create a Buffer.
device.createTexture(props: TextureProps)
Create a Texture.
device.createSampler(props: SamplerProps)Create a Sampler.
device.createFramebuffer(props: FramebufferProps)Create a Framebuffer.
device.createShader(props: ShaderProps)Create a Shader.
device.createRenderPipeline(props: RenderPipelineProps)Create a RenderPipeline (aka program)
device.createComputePipeline(props: ComputePipelineProps)Create a ComputePipeline (aka program)
beginRenderPass(props: RenderPassProps)Create a RenderPass.
beginComputePass(props?: ComputePassProps)Create a ComputePass which can be used to bind data and run compute operations using compute pipelines.