Skip to content
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
Binary file modified examples/screenshots/webgpu_custom_fog_background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgpu_loader_gltf.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgpu_materials_envmaps_bpcem.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
304 changes: 188 additions & 116 deletions src/renderers/webgpu/WebGPUBackend.js

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions src/renderers/webgpu/descriptors/GPUCommandEncoderDescriptor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Reusable descriptor for `GPUDevice.createCommandEncoder()`.
*
* @private
*/
class GPUCommandEncoderDescriptor {

constructor() {

/**
* The label of the command encoder.
*
* @type {string}
*/
this.label = '';

}

/**
* Resets the descriptor to its default state.
*/
reset() {

this.label = '';

}

}

export default GPUCommandEncoderDescriptor;
38 changes: 38 additions & 0 deletions src/renderers/webgpu/descriptors/GPUComputePassDescriptor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Reusable descriptor for `GPUCommandEncoder.beginComputePass()`.
*
* @private
*/
class GPUComputePassDescriptor {

constructor() {

/**
* The label of the compute pass.
*
* @type {string}
*/
this.label = '';

/**
* Defines which timestamp values are written and where.
*
* @type {Object|undefined}
*/
this.timestampWrites = undefined;

}

/**
* Resets the descriptor to its default state.
*/
reset() {

this.label = '';
this.timestampWrites = undefined;

}

}

export default GPUComputePassDescriptor;
47 changes: 47 additions & 0 deletions src/renderers/webgpu/descriptors/GPUCopyExternalImageDestInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import GPUTexelCopyTextureInfo from './GPUTexelCopyTextureInfo.js';

/**
* Reusable descriptor for `GPUCopyExternalImageDestInfo`, the destination
* argument to `GPUQueue.copyExternalImageToTexture()`.
*
* @private
* @augments GPUTexelCopyTextureInfo
*/
class GPUCopyExternalImageDestInfo extends GPUTexelCopyTextureInfo {

constructor() {

super();

/**
* The predefined color space the destination texture is interpreted in.
*
* @type {string}
* @default 'srgb'
*/
this.colorSpace = 'srgb';

/**
* Whether the destination texture has premultiplied alpha.
*
* @type {boolean}
* @default false
*/
this.premultipliedAlpha = false;

}

/**
* Resets the descriptor to its default state.
*/
reset() {

super.reset();
this.colorSpace = 'srgb';
this.premultipliedAlpha = false;

}

}

export default GPUCopyExternalImageDestInfo;
50 changes: 50 additions & 0 deletions src/renderers/webgpu/descriptors/GPUCopyExternalImageSourceInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Reusable descriptor for `GPUCopyExternalImageSourceInfo`, the source argument
* to `GPUQueue.copyExternalImageToTexture()`.
*
* @private
*/
class GPUCopyExternalImageSourceInfo {

constructor() {

/**
* The image-like source.
*
* @type {?(ImageBitmap|ImageData|HTMLImageElement|HTMLVideoElement|VideoFrame|HTMLCanvasElement|OffscreenCanvas)}
* @default null
*/
this.source = null;

/**
* The origin offset within the source.
*
* @type {{x: number, y: number}}
*/
this.origin = { x: 0, y: 0 };

/**
* Whether the source is flipped vertically before copying.
*
* @type {boolean}
* @default false
*/
this.flipY = false;

}

/**
* Resets the descriptor to its default state.
*/
reset() {

this.source = null;
this.origin.x = 0;
this.origin.y = 0;
this.flipY = false;

}

}

export default GPUCopyExternalImageSourceInfo;
51 changes: 51 additions & 0 deletions src/renderers/webgpu/descriptors/GPUExtent3D.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Reusable descriptor for `GPUExtent3D` in its dictionary form, used by
* `GPUQueue.writeTexture()`, `GPUQueue.copyExternalImageToTexture()` and
* the various `GPUCommandEncoder` copy methods.
*
* @private
*/
class GPUExtent3D {

constructor() {

/**
* The width of the extent.
*
* @type {number}
* @default 0
*/
this.width = 0;

/**
* The height of the extent.
*
* @type {number}
* @default 1
*/
this.height = 1;

/**
* The depth (for 3D textures) or number of array layers.
*
* @type {number}
* @default 1
*/
this.depthOrArrayLayers = 1;

}

/**
* Resets the descriptor to its default state.
*/
reset() {

this.width = 0;
this.height = 1;
this.depthOrArrayLayers = 1;

}

}

export default GPUExtent3D;
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* Reusable descriptor for `GPUDevice.createRenderBundleEncoder()`.
*
* @private
*/
class GPURenderBundleEncoderDescriptor {

constructor() {

/**
* The label of the render bundle encoder.
*
* @type {string}
*/
this.label = '';

/**
* The formats of the color attachments the bundle is compatible with.
*
* @type {?Array<?string>}
* @default null
*/
this.colorFormats = null;

/**
* The format of the depth/stencil attachment the bundle is compatible with.
*
* @type {string|undefined}
*/
this.depthStencilFormat = undefined;

/**
* The number of samples per pixel the bundle is compatible with.
*
* @type {number}
* @default 1
*/
this.sampleCount = 1;

/**
* Whether the depth attachment is read-only.
*
* @type {boolean}
* @default false
*/
this.depthReadOnly = false;

/**
* Whether the stencil attachment is read-only.
*
* @type {boolean}
* @default false
*/
this.stencilReadOnly = false;

}

/**
* Resets the descriptor to its default state.
*/
reset() {

this.label = '';
this.colorFormats = null;
this.depthStencilFormat = undefined;
this.sampleCount = 1;
this.depthReadOnly = false;
this.stencilReadOnly = false;

}

}

export default GPURenderBundleEncoderDescriptor;
72 changes: 72 additions & 0 deletions src/renderers/webgpu/descriptors/GPURenderPassColorAttachment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* Reusable descriptor for `GPURenderPassColorAttachment`, the type of each
* entry in `GPURenderPassDescriptor.colorAttachments`.
*
* @private
*/
class GPURenderPassColorAttachment {

constructor() {

/**
* The texture view the pass renders into.
*
* @type {?GPUTextureView}
* @default null
*/
this.view = null;

/**
* The depth slice the pass renders into.
*
* @type {number|undefined}
*/
this.depthSlice = undefined;

/**
* The texture view that receives the resolved output of multisampled rendering.
*
* @type {?GPUTextureView|undefined}
*/
this.resolveTarget = undefined;

/**
* The clear value used when `loadOp` is `'clear'`.
*
* @type {Object|undefined}
*/
this.clearValue = undefined;

/**
* The load operation performed at the start of the pass.
*
* @type {string|undefined}
*/
this.loadOp = undefined;

/**
* The store operation performed at the end of the pass.
*
* @type {string|undefined}
*/
this.storeOp = undefined;

}

/**
* Resets the descriptor to its default state.
*/
reset() {

this.view = null;
this.depthSlice = undefined;
this.resolveTarget = undefined;
this.clearValue = undefined;
this.loadOp = undefined;
this.storeOp = undefined;

}

}

export default GPURenderPassColorAttachment;
Loading
Loading