Limited availability
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is available in Web Workers.
The getConfiguration()
method of the GPUCanvasContext
interface returns the current configuration set for the context.
None.
Return valueAn object containing the configuration options set on the context (i.e., via the GPUCanvasContext.configure()
method), or null
if no configuration is set (either no configuration was previously set, or a configuration was set and then GPUCanvasContext.unconfigure()
was called on the context).
const canvas = document.querySelector("canvas");
const context = canvas.getContext("webgpu");
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();
context.configure({
device,
format: navigator.gpu.getPreferredCanvasFormat(),
alphaMode: "premultiplied",
});
console.log(context.getConfiguration());
/* Logs something like:
{
"alphaMode": "premultiplied",
"colorSpace": "srgb",
"device": { ... },
"format": "bgra8unorm",
"toneMapping": {
"mode": "standard"
},
"usage": 16,
"viewFormats": []
}
*/
Specifications Browser compatibility See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4