Class GPU
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The GPU interface of the {{domxref("WebGPU API", "WebGPU API", "", "nocode")}} is the starting point for using WebGPU. It can be used to return a GPUAdapter from which you can request devices, configure features and limits, and more.
[Value("GPU")]
public class GPU
- Inheritance
-
GPU
- Inherited Members
Remarks
The GPU object for the current context is accessed via the Navigator.Gpu or WorkerNavigator.Gpu properties.
-The WebGPU API
Constructors
GPU()
public GPU()
Properties
WgslLanguageFeatures
The wgslLanguageFeatures read-only property of the
GPU interface returns a WGSLLanguageFeatures object that reports the WGSL language extensions supported by the WebGPU implementation.
[Value("wgslLanguageFeatures")]
public WGSLLanguageFeatures WgslLanguageFeatures { get; }
Property Value
- WGSLLanguageFeatures
A WGSLLanguageFeatures object instance. This is a setlike object.
Remarks
NOTE
Not all WGSL language extensions are available to WebGPU in all browsers that support the API. We recommend you thoroughly test any extensions you choose to use.
Methods
GetPreferredCanvasFormat()
The getPreferredCanvasFormat() method of the
GPU interface returns the optimal canvas texture format for displaying 8-bit depth, standard dynamic range content on the current system.
[Value("getPreferredCanvasFormat")]
public GPUTextureFormat GetPreferredCanvasFormat()
Returns
- GPUTextureFormat
A string indicating a canvas texture format. The value can be
rgba8unormorbgra8unorm.
Remarks
This is commonly used to provide a Configure(GPUCanvasConfiguration) call with the optimal format value for the current system. This is recommended — if you don't use the preferred format when configuring the canvas context, you may incur additional overhead, such as additional texture copies, depending on the platform.
-The WebGPU API
RequestAdapter(GPURequestAdapterOptions)
The requestAdapter() method of the
GPU interface returns a {{jsxref("Promise")}} that fulfills with a GPUAdapter object instance. From this you can request a GPUDevice, adapter info, features, and limits.
[Value("requestAdapter")]
public Task<GPUAdapter?> RequestAdapter(GPURequestAdapterOptions options = null)
Parameters
optionsGPURequestAdapterOptions
Returns
- Task<GPUAdapter>
A {{jsxref("Promise")}} that fulfills with a GPUAdapter object instance if the request is successful.
requestAdapter()will resolve tonullif an appropriate adapter is not available.
Remarks
Note that the user agent chooses whether to return an adapter. If so, it chooses according to the provided options. If no options are provided, the device will provide access to the default adapter, which is usually good enough for most purposes.
-The WebGPU API