Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. GPUDevice

GPUDevice

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.

Note: This feature is available inWeb Workers.

TheGPUDevice interface of theWebGPU API represents a logical GPU device. This is the main interface through which the majority of WebGPU functionality is accessed.

AGPUDevice object is requested using theGPUAdapter.requestDevice() method.

EventTarget GPUDevice

Instance properties

Inherits properties from its parent,EventTarget.

adapterInfoRead only

AGPUAdapterInfo object containing identifying information about the device's originating adapter.

featuresRead only

AGPUSupportedFeatures object that describes additional functionality supported by the device.

label

A string providing a label that can be used to identify the object, for example inGPUError messages or console warnings.

limitsRead only

AGPUSupportedLimits object that describes the limits supported by the device.

lostRead only

Contains aPromise that remains pending throughout the device's lifetime and resolves with aGPUDeviceLostInfo object when the device is lost.

queueRead only

Returns the primaryGPUQueue for the device.

Instance methods

Inherits methods from its parent,EventTarget.

createBindGroup()

Creates aGPUBindGroup based on aGPUBindGroupLayout that defines a set of resources to be bound together in a group and how those resources are used in shader stages.

createBindGroupLayout()

Creates aGPUBindGroupLayout 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 creatingGPUBindGroups.

createBuffer()

Creates aGPUBuffer in which to store raw data to use in GPU operations.

createCommandEncoder()

Creates aGPUCommandEncoder, which is used to encode commands to be issued to the GPU.

createComputePipeline()

Creates aGPUComputePipeline that can control the compute shader stage and be used in aGPUComputePassEncoder.

createComputePipelineAsync()

Returns aPromise that fulfills with aGPUComputePipeline, which can control the compute shader stage and be used in aGPUComputePassEncoder, once the pipeline can be used without any stalling.

createPipelineLayout()

Creates aGPUPipelineLayout that defines theGPUBindGroupLayouts used by a pipeline.GPUBindGroups used with the pipeline during command encoding must have compatibleGPUBindGroupLayouts.

createQuerySet()

Creates aGPUQuerySet that can be used to record the results of queries on passes, such as occlusion or timestamp queries.

createRenderBundleEncoder()

Creates aGPURenderBundleEncoder that can be used to pre-record bundles of commands. These can be reused inGPURenderPassEncoders via theexecuteBundles() method, as many times as required.

createRenderPipeline()

Creates aGPURenderPipeline that can control the vertex and fragment shader stages and be used in aGPURenderPassEncoder orGPURenderBundleEncoder.

createRenderPipelineAsync()

Returns aPromise that fulfills with aGPURenderPipeline, which can control the vertex and fragment shader stages and be used in aGPURenderPassEncoder orGPURenderBundleEncoder, once the pipeline can be used without any stalling.

createSampler()

Creates aGPUSampler, which controls how shaders transform and filter texture resource data.

createShaderModule()

Creates aGPUShaderModule from a string of WGSL source code.

createTexture()

Creates aGPUTexture in which to store texture data to use in GPU rendering operations.

destroy()

Destroys the device, preventing further operations on it.

importExternalTexture()

Takes anHTMLVideoElement as an input and returns aGPUExternalTexture wrapper object containing a snapshot of the video that can be used in GPU rendering operations.

popErrorScope()

Pops an existing GPU error scope from the error scope stack and returns aPromise that resolves to an object (GPUInternalError,GPUOutOfMemoryError, orGPUValidationError) describing the first error captured in the scope, ornull if no error occurred.

pushErrorScope()

Pushes a new GPU error scope onto the device's error scope stack, allowing you to capture errors of a particular type.

Events

uncapturederror

Fired when an error is thrown that has not been observed by a GPU error scope, to provide a way to report unexpected errors. Known error cases should be handled usingpushErrorScope() andpopErrorScope().

Examples

js
async function init() {  if (!navigator.gpu) {    throw Error("WebGPU not supported.");  }  const adapter = await navigator.gpu.requestAdapter();  if (!adapter) {    throw Error("Couldn't request WebGPU adapter.");  }  const device = await adapter.requestDevice();  const shaderModule = device.createShaderModule({    code: shaders,  });  // …}

See the individual member pages listed above and the following demo sites for a lot more examples ofGPUDevice usage:

Specifications

Specification
WebGPU
# gpudevice

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp