GPUDevice


public final class GPUDevice implements AutoCloseable


The primary interface for interacting with the GPU, used to create most resources.

Summary

Public methods

external void
final external @NonNull GPUBindGroup

Creates a new bind group.

final external @NonNull GPUBindGroupLayout

Creates a new bind group layout.

final external @NonNull GPUBuffer

Creates a new GPU buffer.

final external @NonNull GPUCommandEncoder

Creates a new command encoder to record command buffers.

final external @NonNull GPUComputePipeline

Creates a new compute pipeline synchronously.

final @NonNull GPUComputePipeline

Creates a new compute pipeline asynchronously.

final external void

Creates a new compute pipeline asynchronously.

final external @NonNull GPUPipelineLayout

Creates a new pipeline layout.

final external @NonNull GPUQuerySet

Creates a new query set.

final external @NonNull GPURenderBundleEncoder

Creates a new render bundle encoder to record render bundles.

final external @NonNull GPURenderPipeline

Creates a new render pipeline synchronously.

final @NonNull GPURenderPipeline

Creates a new render pipeline asynchronously.

final external void

Creates a new render pipeline asynchronously.

final external @NonNull GPUSampler

Creates a new sampler.

final external @NonNull GPUShaderModule

Creates a new shader module.

final external @NonNull GPUTexture

Creates a new GPU texture.

final external void

Destroys the device and frees its resources.

boolean
equals(Object other)
final external @NonNull GPUAdapterInfo

Gets information about the adapter that was used to create this device.

final external @NonNull GPUSupportedFeatures

Gets the set of features supported by the device.

final long
final external @NonNull GPULimits

Gets the limits supported by the device.

final external @NonNull GPUQueue

Gets the queue object for submitting commands to the GPU.

final external boolean
@FastNative
hasFeature(int feature)

Checks if a specific feature is enabled on the device.

int
final int

Pops the current error scope from the stack asynchronously and returns a possible error.

final external void
@FastNative
popErrorScope(
    @NonNull Executor callbackExecutor,
    @NonNull PopErrorScopeCallback callback
)

Pops the current error scope from the stack asynchronously and returns a possible error.

final external void

Pushes a new error scope onto the device's error scope stack.

final @NonNull GPUQueue
final external void

Sets a debug label for the device.

Public methods

close

Added in 1.0.0-alpha02
public external void close()

createBindGroup

Added in 1.0.0-alpha02
@FastNative
public final external @NonNull GPUBindGroup createBindGroup(@NonNull GPUBindGroupDescriptor descriptor)

Creates a new bind group.

Parameters
@NonNull GPUBindGroupDescriptor descriptor

The descriptor for the bind group.

Returns
@NonNull GPUBindGroup

The newly created bind group.

createBindGroupLayout

Added in 1.0.0-alpha02
@FastNative
public final external @NonNull GPUBindGroupLayout createBindGroupLayout(@NonNull GPUBindGroupLayoutDescriptor descriptor)

Creates a new bind group layout.

Parameters
@NonNull GPUBindGroupLayoutDescriptor descriptor

The descriptor for the bind group layout.

Returns
@NonNull GPUBindGroupLayout

The newly created bind group layout.

createBuffer

Added in 1.0.0-alpha02
@FastNative
public final external @NonNull GPUBuffer createBuffer(@NonNull GPUBufferDescriptor descriptor)

Creates a new GPU buffer.

Parameters
@NonNull GPUBufferDescriptor descriptor

The descriptor for the buffer.

Returns
@NonNull GPUBuffer

The newly created buffer, or {@code null} on failure.

createCommandEncoder

Added in 1.0.0-alpha02
@FastNative
public final external @NonNull GPUCommandEncoder createCommandEncoder(GPUCommandEncoderDescriptor descriptor)

Creates a new command encoder to record command buffers.

Parameters
GPUCommandEncoderDescriptor descriptor

The descriptor for the command encoder.

Returns
@NonNull GPUCommandEncoder

The newly created command encoder.

createComputePipeline

Added in 1.0.0-alpha02
@FastNative
public final external @NonNull GPUComputePipeline createComputePipeline(@NonNull GPUComputePipelineDescriptor descriptor)

Creates a new compute pipeline synchronously.

Parameters
@NonNull GPUComputePipelineDescriptor descriptor

The descriptor for the compute pipeline.

Returns
@NonNull GPUComputePipeline

The newly created compute pipeline.

createComputePipelineAndAwait

public final @NonNull GPUComputePipeline createComputePipelineAndAwait(
    @NonNull GPUComputePipelineDescriptor descriptor
)

Creates a new compute pipeline asynchronously.

Parameters
@NonNull GPUComputePipelineDescriptor descriptor

The descriptor for the compute pipeline.

createComputePipelineAsync

Added in 1.0.0-alpha02
@FastNative
public final external void createComputePipelineAsync(
    @NonNull GPUComputePipelineDescriptor descriptor,
    @NonNull Executor callbackExecutor,
    @NonNull CreateComputePipelineAsyncCallback callback
)

Creates a new compute pipeline asynchronously.

createPipelineLayout

Added in 1.0.0-alpha02
@FastNative
public final external @NonNull GPUPipelineLayout createPipelineLayout(@NonNull GPUPipelineLayoutDescriptor descriptor)

Creates a new pipeline layout.

Parameters
@NonNull GPUPipelineLayoutDescriptor descriptor

The descriptor for the pipeline layout.

Returns
@NonNull GPUPipelineLayout

The newly created pipeline layout.

createQuerySet

Added in 1.0.0-alpha02
@FastNative
public final external @NonNull GPUQuerySet createQuerySet(@NonNull GPUQuerySetDescriptor descriptor)

Creates a new query set.

Parameters
@NonNull GPUQuerySetDescriptor descriptor

The descriptor for the query set.

Returns
@NonNull GPUQuerySet

The newly created query set.

createRenderBundleEncoder

Added in 1.0.0-alpha02
@FastNative
public final external @NonNull GPURenderBundleEncoder createRenderBundleEncoder(
    @NonNull GPURenderBundleEncoderDescriptor descriptor
)

Creates a new render bundle encoder to record render bundles.

Parameters
@NonNull GPURenderBundleEncoderDescriptor descriptor

The descriptor for the render bundle encoder.

Returns
@NonNull GPURenderBundleEncoder

The newly created render bundle encoder.

createRenderPipeline

Added in 1.0.0-alpha02
@FastNative
public final external @NonNull GPURenderPipeline createRenderPipeline(@NonNull GPURenderPipelineDescriptor descriptor)

Creates a new render pipeline synchronously.

Parameters
@NonNull GPURenderPipelineDescriptor descriptor

The descriptor for the render pipeline.

Returns
@NonNull GPURenderPipeline

The newly created render pipeline.

createRenderPipelineAndAwait

public final @NonNull GPURenderPipeline createRenderPipelineAndAwait(
    @NonNull GPURenderPipelineDescriptor descriptor
)

Creates a new render pipeline asynchronously.

Parameters
@NonNull GPURenderPipelineDescriptor descriptor

The descriptor for the render pipeline.

createRenderPipelineAsync

Added in 1.0.0-alpha02
@FastNative
public final external void createRenderPipelineAsync(
    @NonNull GPURenderPipelineDescriptor descriptor,
    @NonNull Executor callbackExecutor,
    @NonNull CreateRenderPipelineAsyncCallback callback
)

Creates a new render pipeline asynchronously.

createSampler

Added in 1.0.0-alpha02
@FastNative
public final external @NonNull GPUSampler createSampler(GPUSamplerDescriptor descriptor)

Creates a new sampler.

Parameters
GPUSamplerDescriptor descriptor

The descriptor for the sampler.

Returns
@NonNull GPUSampler

The newly created sampler.

createShaderModule

Added in 1.0.0-alpha02
@FastNative
public final external @NonNull GPUShaderModule createShaderModule(@NonNull GPUShaderModuleDescriptor descriptor)

Creates a new shader module.

Parameters
@NonNull GPUShaderModuleDescriptor descriptor

The descriptor for the shader module.

Returns
@NonNull GPUShaderModule

The newly created shader module.

createTexture

Added in 1.0.0-alpha02
@FastNative
public final external @NonNull GPUTexture createTexture(@NonNull GPUTextureDescriptor descriptor)

Creates a new GPU texture.

Parameters
@NonNull GPUTextureDescriptor descriptor

The descriptor for the texture.

Returns
@NonNull GPUTexture

The newly created texture.

destroy

Added in 1.0.0-alpha02
@FastNative
public final external void destroy()

Destroys the device and frees its resources. The device becomes lost.

equals

public boolean equals(Object other)

getAdapterInfo

Added in 1.0.0-alpha02
@FastNative
public final external @NonNull GPUAdapterInfo getAdapterInfo()

Gets information about the adapter that was used to create this device.

Returns
@NonNull GPUAdapterInfo

Status code of the operation.

getFeatures

Added in 1.0.0-alpha02
@FastNative
public final external @NonNull GPUSupportedFeatures getFeatures()

Gets the set of features supported by the device.

getHandle

Added in 1.0.0-alpha02
public final long getHandle()

getLimits

Added in 1.0.0-alpha02
@FastNative
public final external @NonNull GPULimits getLimits()

Gets the limits supported by the device.

Returns
@NonNull GPULimits

Status code of the operation.

getQueue

Added in 1.0.0-alpha02
@FastNative
public final external @NonNull GPUQueue getQueue()

Gets the queue object for submitting commands to the GPU.

Returns
@NonNull GPUQueue

The device's queue.

hasFeature

Added in 1.0.0-alpha02
@FastNative
public final external boolean hasFeature(int feature)

Checks if a specific feature is enabled on the device.

Parameters
int feature

The feature to check for support.

Returns
boolean

True if the feature is enabled, {@code false} otherwise.

hashCode

public int hashCode()

popErrorScope

public final int popErrorScope()

Pops the current error scope from the stack asynchronously and returns a possible error.

popErrorScope

Added in 1.0.0-alpha02
@FastNative
public final external void popErrorScope(
    @NonNull Executor callbackExecutor,
    @NonNull PopErrorScopeCallback callback
)

Pops the current error scope from the stack asynchronously and returns a possible error.

pushErrorScope

Added in 1.0.0-alpha02
@FastNative
public final external void pushErrorScope(int filter)

Pushes a new error scope onto the device's error scope stack.

Parameters
int filter

The type of errors to filter and capture in the new scope.

queue

Added in 1.0.0-alpha02
public final @NonNull GPUQueue queue()

setLabel

Added in 1.0.0-alpha02
@FastNative
public final external void setLabel(@NonNull String label)

Sets a debug label for the device.

Parameters
@NonNull String label

The label to assign to the device.