Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

WebGPURenderer: Request all supported features. #25875

Merged
merged 1 commit into from
Apr 18, 2023
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
35 changes: 31 additions & 4 deletions examples/jsm/renderers/webgpu/WebGPURenderer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GPUIndexFormat, GPUTextureFormat } from './constants.js';
import { GPUIndexFormat, GPUTextureFormat, GPUFeatureName } from './constants.js';
import WebGPUAnimation from './WebGPUAnimation.js';
import WebGPURenderObjects from './WebGPURenderObjects.js';
import WebGPUAttributes from './WebGPUAttributes.js';
Expand Down Expand Up @@ -167,7 +167,6 @@ class WebGPURenderer {

}

this._parameters.requiredFeatures = ( parameters.requiredFeatures === undefined ) ? [] : parameters.requiredFeatures;
this._parameters.requiredLimits = ( parameters.requiredLimits === undefined ) ? {} : parameters.requiredLimits;

// backwards compatibility
Expand Down Expand Up @@ -200,8 +199,36 @@ class WebGPURenderer {

}

// feature support

const features = [
GPUFeatureName.DepthClipControl,
GPUFeatureName.Depth32FloatStencil8,
GPUFeatureName.TextureCompressionBC,
GPUFeatureName.TextureCompressionETC2,
GPUFeatureName.TextureCompressionASTC,
GPUFeatureName.TimestampQuery,
GPUFeatureName.IndirectFirstInstance,
GPUFeatureName.ShaderF16,
GPUFeatureName.RG11B10UFloat,
GPUFeatureName.BGRA8UNormStorage,
GPUFeatureName.Float32Filterable
];

const supportedFeatures = [];

for ( const name of features ) {

if ( adapter.features.has( name ) ) {

supportedFeatures.push( name );

}

}

const deviceDescriptor = {
requiredFeatures: parameters.requiredFeatures,
requiredFeatures: supportedFeatures,
Mugen87 marked this conversation as resolved.
Show resolved Hide resolved
requiredLimits: parameters.requiredLimits
};

Expand Down Expand Up @@ -254,7 +281,7 @@ class WebGPURenderer {

const nodeFrame = this._nodes.nodeFrame;

let previousRenderId = nodeFrame.renderId;
const previousRenderId = nodeFrame.renderId;
nodeFrame.renderId ++;

if ( this._animation.isAnimating === false ) nodeFrame.update();
Expand Down
14 changes: 14 additions & 0 deletions examples/jsm/renderers/webgpu/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,20 @@ export const GPUInputStepMode = {
Instance: 'instance'
};

export const GPUFeatureName = {
DepthClipControl: 'depth-clip-control',
Depth32FloatStencil8: 'depth32float-stencil8',
TextureCompressionBC: 'texture-compression-bc',
TextureCompressionETC2: 'texture-compression-etc2',
TextureCompressionASTC: 'texture-compression-astc',
TimestampQuery: 'timestamp-query',
IndirectFirstInstance: 'indirect-first-instance',
ShaderF16: 'shader-f16',
RG11B10UFloat: 'rg11b10ufloat-renderable',
BGRA8UNormStorage: 'bgra8unorm-storage',
Float32Filterable: 'float32-filterable'
};

export const GPUChunkSize = 16; // size of a chunk in bytes (STD140 layout)

// @TODO: Move to src/constants.js
Expand Down
2 changes: 1 addition & 1 deletion examples/webgpu_sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

//

renderer = new WebGPURenderer( { requiredFeatures: [ 'texture-compression-bc', 'texture-compression-astc' ] } );
renderer = new WebGPURenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setAnimationLoop( animate );
Expand Down
2 changes: 1 addition & 1 deletion examples/webgpu_sprites.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@

//

renderer = new WebGPURenderer( { requiredFeatures: [ 'texture-compression-bc' ] } );
renderer = new WebGPURenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setAnimationLoop( render );
Expand Down