Skip to content

Commit ee2a5f2

Browse files
authored
WebGPURenderer: Request all supported features. (#25875)
1 parent 883df2e commit ee2a5f2

File tree

4 files changed

+47
-6
lines changed

4 files changed

+47
-6
lines changed

examples/jsm/renderers/webgpu/WebGPURenderer.js

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { GPUIndexFormat, GPUTextureFormat } from './constants.js';
1+
import { GPUIndexFormat, GPUTextureFormat, GPUFeatureName } from './constants.js';
22
import WebGPUAnimation from './WebGPUAnimation.js';
33
import WebGPURenderObjects from './WebGPURenderObjects.js';
44
import WebGPUAttributes from './WebGPUAttributes.js';
@@ -167,7 +167,6 @@ class WebGPURenderer {
167167

168168
}
169169

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

173172
// backwards compatibility
@@ -200,8 +199,36 @@ class WebGPURenderer {
200199

201200
}
202201

202+
// feature support
203+
204+
const features = [
205+
GPUFeatureName.DepthClipControl,
206+
GPUFeatureName.Depth32FloatStencil8,
207+
GPUFeatureName.TextureCompressionBC,
208+
GPUFeatureName.TextureCompressionETC2,
209+
GPUFeatureName.TextureCompressionASTC,
210+
GPUFeatureName.TimestampQuery,
211+
GPUFeatureName.IndirectFirstInstance,
212+
GPUFeatureName.ShaderF16,
213+
GPUFeatureName.RG11B10UFloat,
214+
GPUFeatureName.BGRA8UNormStorage,
215+
GPUFeatureName.Float32Filterable
216+
];
217+
218+
const supportedFeatures = [];
219+
220+
for ( const name of features ) {
221+
222+
if ( adapter.features.has( name ) ) {
223+
224+
supportedFeatures.push( name );
225+
226+
}
227+
228+
}
229+
203230
const deviceDescriptor = {
204-
requiredFeatures: parameters.requiredFeatures,
231+
requiredFeatures: supportedFeatures,
205232
requiredLimits: parameters.requiredLimits
206233
};
207234

@@ -254,7 +281,7 @@ class WebGPURenderer {
254281

255282
const nodeFrame = this._nodes.nodeFrame;
256283

257-
let previousRenderId = nodeFrame.renderId;
284+
const previousRenderId = nodeFrame.renderId;
258285
nodeFrame.renderId ++;
259286

260287
if ( this._animation.isAnimating === false ) nodeFrame.update();

examples/jsm/renderers/webgpu/constants.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,20 @@ export const GPUInputStepMode = {
299299
Instance: 'instance'
300300
};
301301

302+
export const GPUFeatureName = {
303+
DepthClipControl: 'depth-clip-control',
304+
Depth32FloatStencil8: 'depth32float-stencil8',
305+
TextureCompressionBC: 'texture-compression-bc',
306+
TextureCompressionETC2: 'texture-compression-etc2',
307+
TextureCompressionASTC: 'texture-compression-astc',
308+
TimestampQuery: 'timestamp-query',
309+
IndirectFirstInstance: 'indirect-first-instance',
310+
ShaderF16: 'shader-f16',
311+
RG11B10UFloat: 'rg11b10ufloat-renderable',
312+
BGRA8UNormStorage: 'bgra8unorm-storage',
313+
Float32Filterable: 'float32-filterable'
314+
};
315+
302316
export const GPUChunkSize = 16; // size of a chunk in bytes (STD140 layout)
303317

304318
// @TODO: Move to src/constants.js

examples/webgpu_sandbox.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757

5858
//
5959

60-
renderer = new WebGPURenderer( { requiredFeatures: [ 'texture-compression-bc', 'texture-compression-astc' ] } );
60+
renderer = new WebGPURenderer();
6161
renderer.setPixelRatio( window.devicePixelRatio );
6262
renderer.setSize( window.innerWidth, window.innerHeight );
6363
renderer.setAnimationLoop( animate );

examples/webgpu_sprites.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107

108108
//
109109

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

0 commit comments

Comments
 (0)