Class GPUDevice
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The GPUDevice interface of the {{domxref("WebGPU API", "WebGPU API", "", "nocode")}} represents a logical GPU device. This is the main interface through which the majority of WebGPU functionality is accessed.
[Value("GPUDevice")]
public class GPUDevice : EventTarget, GPUObjectBase
- Inheritance
-
GPUDevice
- Implements
- Inherited Members
Remarks
A GPUDevice object is requested using the RequestDevice(GPUDeviceDescriptor) method.
-The WebGPU API
Constructors
GPUDevice()
public GPUDevice()
Properties
AdapterInfo
The adapterInfo read-only property of the
GPUDevice interface returns a GPUAdapterInfo object containing identifying information about the device's originating adapter.
[Value("adapterInfo")]
public GPUAdapterInfo AdapterInfo { get; }
Property Value
- GPUAdapterInfo
A GPUAdapterInfo object instance.
Remarks
Features
The features read-only property of the
GPUDevice interface returns a GPUSupportedFeatures object that describes additional functionality supported by the device. Only features requested during the creation of the device (i.e., when RequestDevice(GPUDeviceDescriptor) is called) are included.
[Value("features")]
public GPUSupportedFeatures Features { get; }
Property Value
- GPUSupportedFeatures
A GPUSupportedFeatures object instance. This is a setlike object.
Remarks
NOTE
Not all features will be available to WebGPU in all browsers that support it, even if the features are supported by the underlying hardware. See Features for more details.
-The WebGPU API
Limits
The limits read-only property of the
GPUDevice interface returns a GPUSupportedLimits object that describes the limits supported by the device. All limit values will be included, and the limits requested during the creation of the device (i.e., when RequestDevice(GPUDeviceDescriptor) is called) will be reflected in those values.
[Value("limits")]
public GPUSupportedLimits Limits { get; }
Property Value
- GPUSupportedLimits
A GPUSupportedLimits object instance.
Remarks
NOTE
Not all limits will be reported as expected, even if they are supported by the underlying hardware. See Limits for more details.
-The WebGPU API
Lost
The lost read-only property of the
GPUDevice interface contains a {{jsxref("Promise")}} that remains pending throughout the device's lifetime and resolves with a GPUDeviceLostInfo object when the device is lost.
[Value("lost")]
public Task<GPUDeviceLostInfo> Lost { get; }
Property Value
- Task<GPUDeviceLostInfo>
A promise that resolves with a GPUDeviceLostInfo object when the device is lost.
Remarks
RequestDevice(GPUDeviceDescriptor) will never return null, and it will reject only if the request is invalid, i.e., it exceeds the capabilities of the GPUAdapter. If a valid device request can't be fulfilled for some reason however it may resolve to a device that has already been lost. Additionally, devices can be lost at any time after creation for a variety of reasons (such as browser resource management or driver updates), so it's a good idea to always handle lost devices gracefully.
Many causes for lost devices are transient, so you should try getting a new device once a previous one has been lost unless the loss was caused by the application intentionally destroying the device (i.e., with Destroy()). Note that any WebGPU resources created with a previous device (buffers, textures, etc.) will need to be re-created with the new one.
NOTE
Also bear in mind that a
GPUAdaptermay become unavailable, e.g., if the physical GPU is unplugged from the system or disabled to save power. From then on, the adapter can no longer return valid devices, and will always return already-lost devices.
-The WebGPU API
Onuncapturederror
[Value("onuncapturederror")]
public EventHandlerNonNull Onuncapturederror { get; set; }
Property Value
Queue
[Value("queue")]
public GPUQueue Queue { get; }
Property Value
Remarks
Methods
CreateBindGroup(GPUBindGroupDescriptor)
The createBindGroup() method of the
GPUDevice interface creates a GPUBindGroup based on a GPUBindGroupLayout that defines a set of resources to be bound together in a group and how those resources are used in shader stages.
[Value("createBindGroup")]
public GPUBindGroup CreateBindGroup(GPUBindGroupDescriptor descriptor)
Parameters
descriptorGPUBindGroupDescriptor
Returns
- GPUBindGroup
A GPUBindGroup object instance.
Remarks
CreateBindGroupLayout(GPUBindGroupLayoutDescriptor)
The createBindGroupLayout() method of the
GPUDevice interface creates a GPUBindGroupLayout that defines the structure and purpose of related GPU resources such as buffers that will be used in a pipeline, and is used as a template when creating GPUBindGroups.
[Value("createBindGroupLayout")]
public GPUBindGroupLayout CreateBindGroupLayout(GPUBindGroupLayoutDescriptor descriptor)
Parameters
descriptorGPUBindGroupLayoutDescriptor
Returns
- GPUBindGroupLayout
A GPUBindGroupLayout object instance.
Remarks
CreateBuffer(GPUBufferDescriptor)
The createBuffer() method of the
GPUDevice interface creates a GPUBuffer in which to store raw data to use in GPU operations.
[Value("createBuffer")]
public GPUBuffer CreateBuffer(GPUBufferDescriptor descriptor)
Parameters
descriptorGPUBufferDescriptor
Returns
Remarks
CreateCommandEncoder(GPUCommandEncoderDescriptor)
The createCommandEncoder() method of the
GPUDevice interface creates a GPUCommandEncoder, used to encode commands to be issued to the GPU.
[Value("createCommandEncoder")]
public GPUCommandEncoder CreateCommandEncoder(GPUCommandEncoderDescriptor descriptor = null)
Parameters
descriptorGPUCommandEncoderDescriptor
Returns
- GPUCommandEncoder
A GPUCommandEncoder object instance.
Remarks
CreateComputePipeline(GPUComputePipelineDescriptor)
The createComputePipeline() method of the
GPUDevice interface creates a GPUComputePipeline that can control the compute shader stage and be used in a GPUComputePassEncoder.
[Value("createComputePipeline")]
public GPUComputePipeline CreateComputePipeline(GPUComputePipelineDescriptor descriptor)
Parameters
descriptorGPUComputePipelineDescriptor
Returns
- GPUComputePipeline
A GPUComputePipeline object instance.
Remarks
CreateComputePipelineAsync(GPUComputePipelineDescriptor)
The createComputePipelineAsync() method of the
GPUDevice interface returns a {{jsxref("Promise")}} that fulfills with a GPUComputePipeline, which can control the compute shader stage and be used in a GPUComputePassEncoder, once the pipeline can be used without any stalling.
[Value("createComputePipelineAsync")]
public Task<GPUComputePipeline> CreateComputePipelineAsync(GPUComputePipelineDescriptor descriptor)
Parameters
descriptorGPUComputePipelineDescriptor
Returns
- Task<GPUComputePipeline>
A {{jsxref("Promise")}} that fulfills with a GPUComputePipeline object instance when the created pipeline is ready to be used without additional delay.
Remarks
NOTE
It is generally preferable to use this method over CreateComputePipeline(GPUComputePipelineDescriptor) whenever possible, as it prevents blocking of GPU operation execution on pipeline compilation.
-The WebGPU API
CreatePipelineLayout(GPUPipelineLayoutDescriptor)
The createPipelineLayout() method of the
GPUDevice interface creates a GPUPipelineLayout that defines the GPUBindGroupLayouts used by a pipeline. GPUBindGroups used with the pipeline during command encoding must have compatible GPUBindGroupLayouts.
[Value("createPipelineLayout")]
public GPUPipelineLayout CreatePipelineLayout(GPUPipelineLayoutDescriptor descriptor)
Parameters
descriptorGPUPipelineLayoutDescriptor
Returns
- GPUPipelineLayout
A GPUPipelineLayout object instance.
Remarks
CreateQuerySet(GPUQuerySetDescriptor)
The createQuerySet() method of the
GPUDevice interface creates a GPUQuerySet that can be used to record the results of queries on passes, such as occlusion or timestamp queries.
[Value("createQuerySet")]
public GPUQuerySet CreateQuerySet(GPUQuerySetDescriptor descriptor)
Parameters
descriptorGPUQuerySetDescriptor
Returns
- GPUQuerySet
A GPUQuerySet object instance.
Remarks
CreateRenderBundleEncoder(GPURenderBundleEncoderDescriptor)
The createRenderBundleEncoder() method of the
GPUDevice interface creates a GPURenderBundleEncoder that can be used to pre-record bundles of commands. These can be reused in GPURenderPassEncoders via the ExecuteBundles(List<GPURenderBundle>) method, as many times as required.
[Value("createRenderBundleEncoder")]
public GPURenderBundleEncoder CreateRenderBundleEncoder(GPURenderBundleEncoderDescriptor descriptor)
Parameters
descriptorGPURenderBundleEncoderDescriptor
Returns
- GPURenderBundleEncoder
A GPURenderBundleEncoder object instance.
Remarks
CreateRenderPipeline(GPURenderPipelineDescriptor)
The createRenderPipeline() method of the
GPUDevice interface creates a GPURenderPipeline that can control the vertex and fragment shader stages and be used in a GPURenderPassEncoder or GPURenderBundleEncoder.
[Value("createRenderPipeline")]
public GPURenderPipeline CreateRenderPipeline(GPURenderPipelineDescriptor descriptor)
Parameters
descriptorGPURenderPipelineDescriptor
Returns
- GPURenderPipeline
A GPURenderPipeline object instance.
Remarks
CreateRenderPipelineAsync(GPURenderPipelineDescriptor)
The createRenderPipelineAsync() method of the
GPUDevice interface returns a {{jsxref("Promise")}} that fulfills with a GPURenderPipeline, which can control the vertex and fragment shader stages and be used in a GPURenderPassEncoder or GPURenderBundleEncoder, once the pipeline can be used without any stalling.
[Value("createRenderPipelineAsync")]
public Task<GPURenderPipeline> CreateRenderPipelineAsync(GPURenderPipelineDescriptor descriptor)
Parameters
descriptorGPURenderPipelineDescriptor
Returns
- Task<GPURenderPipeline>
A {{jsxref("Promise")}} that fulfills with a GPURenderPipeline object instance when the created pipeline is ready to be used without additional delay.
Remarks
NOTE
It is generally preferable to use this method over CreateRenderPipeline(GPURenderPipelineDescriptor) whenever possible, as it prevents blocking of GPU operation execution on pipeline compilation.
-The WebGPU API
CreateSampler(GPUSamplerDescriptor)
The createSampler() method of the
GPUDevice interface creates a GPUSampler, which controls how shaders transform and filter texture resource data.
[Value("createSampler")]
public GPUSampler CreateSampler(GPUSamplerDescriptor descriptor = null)
Parameters
descriptorGPUSamplerDescriptor
Returns
- GPUSampler
A GPUSampler object instance.
Remarks
CreateShaderModule(GPUShaderModuleDescriptor)
The createShaderModule() method of the
GPUDevice interface creates a GPUShaderModule from a string of WGSL source code.
[Value("createShaderModule")]
public GPUShaderModule CreateShaderModule(GPUShaderModuleDescriptor descriptor)
Parameters
descriptorGPUShaderModuleDescriptor
Returns
- GPUShaderModule
A GPUShaderModule object instance.
Remarks
CreateTexture(GPUTextureDescriptor)
The createTexture() method of the
GPUDevice interface creates a GPUTexture in which to store 1D, 2D, or 3D arrays of data, such as images, to use in GPU rendering operations.
[Value("createTexture")]
public GPUTexture CreateTexture(GPUTextureDescriptor descriptor)
Parameters
descriptorGPUTextureDescriptor
Returns
- GPUTexture
A GPUTexture object instance.
Remarks
Destroy()
The destroy() method of the
GPUDevice interface destroys the device, preventing further operations on it.
[Value("destroy")]
public GlobalObject.Undefined Destroy()
Returns
Remarks
ImportExternalTexture(GPUExternalTextureDescriptor)
The importExternalTexture() method of the
GPUDevice interface takes an HTMLVideoElement or a VideoFrame object as an input and returns a GPUExternalTexture wrapper object containing a snapshot of the video that can be used as a frame in GPU rendering operations.
[Value("importExternalTexture")]
public GPUExternalTexture ImportExternalTexture(GPUExternalTextureDescriptor descriptor)
Parameters
descriptorGPUExternalTextureDescriptor
Returns
- GPUExternalTexture
A GPUExternalTexture object instance.Note that the moment when the GPUExternalTexture object expires (is destroyed) depends on what its source is:
Remarks
PopErrorScope()
The popErrorScope() method of the
GPUDevice interface pops an existing GPU error scope from the error scope stack (originally pushed using PushErrorScope(GPUErrorFilter)) and returns a {{jsxref("Promise")}} that resolves to an object describing the first error captured in the scope, or null if no error occurred.
[Value("popErrorScope")]
public Task<GPUError?> PopErrorScope()
Returns
- Task<GPUError>
a Promise that resolves to an object describing the first error captured in the scope. This can be of type:If no error occurred, it resolves to
null.
Remarks
PushErrorScope(GPUErrorFilter)
The pushErrorScope() method of the
GPUDevice interface pushes a new GPU error scope onto the device's error scope stack, allowing you to capture errors of a particular type.
[Value("pushErrorScope")]
public GlobalObject.Undefined PushErrorScope(GPUErrorFilter filter)
Parameters
filterGPUErrorFilter
Returns
Remarks
Once you are done capturing errors, you can end capture by invoking PopErrorScope(). This pops the scope from the stack and returns a {{jsxref("Promise")}} that resolves to an object describing the first error captured in the scope, or null if no errors were captured.
-The WebGPU API