Aller au contenu

GPUDevice

A GPUDevice encapsulates a device and exposes the functionality of that device. ## Lifetime `close()` destroys the device and triggers the loss notification observed by `awaitLost`, with the destruction reason when the backend provides one. Closing an already closed device does not release the same reference a second time.

Properties

adapterInfo

Information about the physical adapter which created the device that this GPUDevice refers to. For a given GPUDevice, the GPUAdapterInfo values exposed are constant over time.

features

A set containing the GPUFeatureName values of the features supported by the device ([device].[[`features`](index.md#features)]).

label

abstract var label: String
A developer-provided label which is used in an implementation-defined way. It can be used by the browser, OS, or other tools to help identify the underlying internal object to the developer. Examples include displaying the label in GPUError messages, console warnings, browser developer tools, and platform debugging utilities.

limits

abstract val limits: GPUSupportedLimits
The limits supported by the device ([device].[[`limits`](index.md#limits)]).

queue

abstract val queue: GPUQueue
The primary GPUQueue for this device. See [GPUDevice.queue in the WebGPU specification](https://www.w3.org/TR/webgpu/#dom-gpudevice-queue).

Functions

awaitLost

abstract suspend fun awaitLost(): Result<GPUDeviceLostInfo>
Waits until this device is lost and resolves with the loss information. The loss is a successful result: it carries a [`GPUDeviceLostReason`](../-g-p-u-device-lost-reason/index.md) and an implementation-provided message, it is not a failure of the returned [`Result`](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-result/index.html). Several observers may wait at the same time and all of them observe the same loss; an observer that starts waiting after the loss resolves immediately. Cancelling one observer neither cancels the other observers nor destroys the device. Closing the device explicitly notifies the loss with the destruction reason when the backend provides one.

close

expect abstract fun close()

createBindGroup

Creates a GPUBindGroup. **Parameters** - descriptor: Description of the GPUBindGroup to create.

createBindGroupLayout

Creates a GPUBindGroupLayout. **Parameters** - descriptor: Description of the GPUBindGroupLayout to create.

createBuffer

abstract fun createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer
Creates a GPUBuffer. **Parameters** - descriptor: Description of the GPUBuffer to create.

createCommandEncoder

Creates a GPUCommandEncoder. **Parameters** - descriptor: Description of the GPUCommandEncoder to create.

createComputePipeline

Creates a GPUComputePipeline using immediate pipeline creation. **Parameters** - descriptor: Description of the GPUComputePipeline to create.

createComputePipelineAsync

Creates a GPUComputePipeline using async pipeline creation. The returned Promise resolves when the created pipeline is ready to be used without additional delay. If pipeline creation fails, the returned Promise rejects with an GPUPipelineError. (A GPUError is not dispatched to the device.) **Parameters** - descriptor: Description of the GPUComputePipeline to create.

createPipelineLayout

Creates a GPUPipelineLayout. **Parameters** - descriptor: Description of the GPUPipelineLayout to create.

createQuerySet

Creates a GPUQuerySet. **Parameters** - descriptor: Description of the GPUQuerySet to create.

createRenderBundleEncoder

Creates a GPURenderBundleEncoder. **Parameters** - descriptor: Description of the GPURenderBundleEncoder to create.

createRenderPipeline

Creates a GPURenderPipeline using immediate pipeline creation. **Parameters** - descriptor: Description of the GPURenderPipeline to create.

createRenderPipelineAsync

Creates a GPURenderPipeline using async pipeline creation. The returned Promise resolves when the created pipeline is ready to be used without additional delay. If pipeline creation fails, the returned Promise rejects with an GPUPipelineError. (A GPUError is not dispatched to the device.) **Parameters** - descriptor: Description of the GPURenderPipeline to create.

createSampler

abstract fun createSampler(descriptor: GPUSamplerDescriptor? = null): GPUSampler
Creates a GPUSampler. **Parameters** - descriptor: Description of the GPUSampler to create.

createShaderModule

Creates a GPUShaderModule. **Parameters** - descriptor: Description of the GPUShaderModule to create.

createTexture

abstract fun createTexture(descriptor: GPUTextureDescriptor): GPUTexture
Creates a GPUTexture. **Parameters** - descriptor: Description of the GPUTexture to create.

popErrorScope

abstract suspend fun popErrorScope(): Result<GPUError?>
Pops a GPU error scope off the [errorScopeStack] for this and resolves to any GPUError observed by the error scope, or null if none. There is no guarantee of the ordering of promise resolution.

pushErrorScope

abstract fun pushErrorScope(filter: GPUErrorFilter)
Pushes a new GPU error scope onto the [errorScopeStack] for this. **Parameters** - filter: Which class of errors this error scope observes.