MCPcopy Index your code
hub / github.com/processing/p5.js / _initContext

Method _initContext

src/webgpu/p5.RendererWebGPU.js:462–486  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

460 }
461
462 async _initContext() {
463 this.adapter = await navigator.gpu?.requestAdapter(this._webgpuAttributes);
464 this.device = await this.adapter?.requestDevice({
465 // Todo: check support
466 requiredFeatures: ['depth32float-stencil8']
467 });
468 if (!this.device) {
469 throw new Error('Your browser does not support WebGPU.');
470 }
471 this.queue = this.device.queue;
472 this.drawingContext = this.canvas.getContext('webgpu');
473 this.presentationFormat = navigator.gpu.getPreferredCanvasFormat();
474 this.drawingContext.configure({
475 device: this.device,
476 format: this.presentationFormat,
477 usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
478 alphaMode: 'premultiplied',
479 });
480
481 // TODO disablable stencil
482 this.mainFramebuffer = this.createFramebuffer({ _useCanvasFormat: true });
483 this._updateSize();
484 this._update();
485 this.flushDraw();
486 }
487
488 async _setAttributes(key, value) {
489 if (typeof this._pInst._webgpuAttributes === "undefined") {

Callers 1

setupContextMethod · 0.95

Calls 4

_updateSizeMethod · 0.95
flushDrawMethod · 0.95
createFramebufferMethod · 0.45
_updateMethod · 0.45

Tested by

no test coverage detected