Skip to content

Commit

Permalink
Merge pull request #15702 from Popov72/webgpu-adapterinfo
Browse files Browse the repository at this point in the history
WebGPU: Fix requestAdapterInfo removed from the spec
  • Loading branch information
sebavan authored Oct 15, 2024
2 parents 281732a + 0664d91 commit 96d8f17
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions packages/dev/core/src/Engines/webgpuEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ export interface GlslangOptions {
* Options to create the WebGPU engine
*/
export interface WebGPUEngineOptions extends AbstractEngineOptions, GPURequestAdapterOptions {
/**
* The featureLevel property of the GPURequestAdapterOptions interface
*/
featureLevel?: string;

/**
* Defines the category of adapter to use.
* Is it the discrete or integrated device.
Expand Down Expand Up @@ -639,10 +644,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
this._adapterSupportedExtensions = [];
this._adapter.features?.forEach((feature) => this._adapterSupportedExtensions.push(feature as WebGPUConstants.FeatureName));
this._adapterSupportedLimits = this._adapter.limits;

this._adapter.requestAdapterInfo().then((adapterInfo) => {
this._adapterInfo = adapterInfo;
});
this._adapterInfo = this._adapter.info;

const deviceDescriptor = this._options.deviceDescriptor ?? {};
const requiredFeatures = deviceDescriptor?.requiredFeatures ?? (this._options.enableAllFeatures ? this._adapterSupportedExtensions : undefined);
Expand Down
3 changes: 2 additions & 1 deletion packages/dev/core/src/LibDeclarations/webgpu.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ declare class GPU {
}

interface GPURequestAdapterOptions {
featureLevel?: string;
powerPreference?: GPUPowerPreference;
forceFallbackAdapter?: boolean /* default=false */;
}
Expand All @@ -83,10 +84,10 @@ declare class GPUAdapter {
readonly name: string;
readonly features: GPUSupportedFeatures;
readonly limits: GPUSupportedLimits;
readonly info: GPUAdapterInfo;
readonly isFallbackAdapter: boolean;

requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice>;
requestAdapterInfo(unmaskHints?: string[]): Promise<GPUAdapterInfo>;
}

interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
Expand Down

0 comments on commit 96d8f17

Please sign in to comment.