Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

WebGPURenderer: Update to latest API. #22034

Merged
merged 1 commit into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions examples/jsm/renderers/webgpu/WebGPURenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}

Expand All @@ -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 );
Expand All @@ -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)
} );
Expand Down Expand Up @@ -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;

}
Expand Down
10 changes: 5 additions & 5 deletions examples/jsm/renderers/webgpu/WebGPUTextures.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down Expand Up @@ -416,19 +416,19 @@ 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 } );

} );

}

}

_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,
Expand Down
2 changes: 1 addition & 1 deletion examples/webgpu_sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down