From 6cd4a73183ea89c541ee5c840fa746e06da30fd0 Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Tue, 22 Jun 2021 21:01:36 +0200 Subject: [PATCH] WebGPURenderer: Update to latest API. --- examples/jsm/renderers/webgpu/WebGPURenderer.js | 14 +++++++------- examples/jsm/renderers/webgpu/WebGPUTextures.js | 10 +++++----- examples/webgpu_sandbox.html | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/jsm/renderers/webgpu/WebGPURenderer.js b/examples/jsm/renderers/webgpu/WebGPURenderer.js index 8e482b464a0d1a..e7866245d3e299 100644 --- a/examples/jsm/renderers/webgpu/WebGPURenderer.js +++ b/examples/jsm/renderers/webgpu/WebGPURenderer.js @@ -138,8 +138,8 @@ class WebGPURenderer { } - this._parameters.nonGuaranteedFeatures = ( parameters.nonGuaranteedFeatures === undefined ) ? [] : parameters.nonGuaranteedFeatures; - this._parameters.nonGuaranteedLimits = ( parameters.nonGuaranteedLimits === undefined ) ? {} : parameters.nonGuaranteedLimits; + this._parameters.requiredFeatures = ( parameters.requiredFeatures === undefined ) ? [] : parameters.requiredFeatures; + this._parameters.requiredLimits = ( parameters.requiredLimits === undefined ) ? {} : parameters.requiredLimits; } @@ -154,8 +154,8 @@ class WebGPURenderer { const adapter = await navigator.gpu.requestAdapter( adapterOptions ); const deviceDescriptor = { - nonGuaranteedFeatures: parameters.nonGuaranteedFeatures, - nonGuaranteedLimits: parameters.nonGuaranteedLimits + requiredFeatures: parameters.requiredFeatures, + requiredLimits: parameters.requiredLimits }; const device = await adapter.requestDevice( deviceDescriptor ); @@ -164,7 +164,7 @@ class WebGPURenderer { const context = ( parameters.context !== undefined ) ? parameters.context : this.domElement.getContext( 'gpupresent' ); - const swapChain = context.configureSwapChain( { + const swapChain = context.configure( { device: device, format: GPUTextureFormat.BRGA8Unorm // this is the only valid swap chain format right now (r121) } ); @@ -256,11 +256,11 @@ class WebGPURenderer { if ( this._parameters.antialias === true ) { colorAttachment.view = this._colorBuffer.createView(); - colorAttachment.resolveTarget = this._swapChain.getCurrentTexture().createView(); + colorAttachment.resolveTarget = this._context.getCurrentTexture().createView(); } else { - colorAttachment.view = this._swapChain.getCurrentTexture().createView(); + colorAttachment.view = this._context.getCurrentTexture().createView(); colorAttachment.resolveTarget = undefined; } diff --git a/examples/jsm/renderers/webgpu/WebGPUTextures.js b/examples/jsm/renderers/webgpu/WebGPUTextures.js index 065ab7cda88eae..685c03d10aa816 100644 --- a/examples/jsm/renderers/webgpu/WebGPUTextures.js +++ b/examples/jsm/renderers/webgpu/WebGPUTextures.js @@ -366,7 +366,7 @@ class WebGPUTextures { this._getImageBitmap( image, texture ).then( imageBitmap => { - this._copyImageBitmapToTexture( imageBitmap, textureGPU ); + this._copyExternalImageToTexture( imageBitmap, textureGPU ); if ( needsMipmaps === true ) this._generateMipmaps( textureGPU, textureGPUDescriptor ); @@ -416,7 +416,7 @@ class WebGPUTextures { this._getImageBitmap( image, texture ).then( imageBitmap => { - this._copyImageBitmapToTexture( imageBitmap, textureGPU, { x: 0, y: 0, z: i } ); + this._copyExternalImageToTexture( imageBitmap, textureGPU, { x: 0, y: 0, z: i } ); } ); @@ -424,11 +424,11 @@ class WebGPUTextures { } - _copyImageBitmapToTexture( image, textureGPU, origin = { x: 0, y: 0, z: 0 } ) { + _copyExternalImageToTexture( image, textureGPU, origin = { x: 0, y: 0, z: 0 } ) { - this.device.queue.copyImageBitmapToTexture( + this.device.queue.copyExternalImageToTexture( { - imageBitmap: image + source: image }, { texture: textureGPU, mipLevel: 0, diff --git a/examples/webgpu_sandbox.html b/examples/webgpu_sandbox.html index c4fdaaf8c05e2e..bdd81cad75fd16 100644 --- a/examples/webgpu_sandbox.html +++ b/examples/webgpu_sandbox.html @@ -177,7 +177,7 @@ // - renderer = new WebGPURenderer( { nonGuaranteedFeatures: [ 'texture-compression-bc' ] } ); + renderer = new WebGPURenderer( { requiredFeatures: [ 'texture-compression-bc' ] } ); renderer.setPixelRatio( window.devicePixelRatio ); renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement );