From d868f7cb16ab6f259025f11f0e18dbb596bc503f Mon Sep 17 00:00:00 2001 From: Arthur Islamov Date: Mon, 11 Sep 2023 23:54:39 +0400 Subject: [PATCH] Small fixes --- js/web/lib/wasm/jsep/backend-webgpu.ts | 9 +++------ js/web/lib/wasm/jsep/webgpu/ops/common.ts | 4 ++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/js/web/lib/wasm/jsep/backend-webgpu.ts b/js/web/lib/wasm/jsep/backend-webgpu.ts index cac2e5c7db5f0..e6e78df2cfb23 100644 --- a/js/web/lib/wasm/jsep/backend-webgpu.ts +++ b/js/web/lib/wasm/jsep/backend-webgpu.ts @@ -110,7 +110,7 @@ export class WebGpuBackend { } this.env = env; - const requiredFeatures = []; + const requiredFeatures: GPUFeatureName[] = []; const deviceDescriptor: GPUDeviceDescriptor = { requiredLimits: { maxComputeWorkgroupStorageSize: adapter.limits.maxComputeWorkgroupStorageSize, @@ -122,20 +122,17 @@ export class WebGpuBackend { maxComputeWorkgroupSizeY: adapter.limits.maxComputeWorkgroupSizeY, maxComputeWorkgroupSizeZ: adapter.limits.maxComputeWorkgroupSizeZ, }, - requiredFeatures: [], + requiredFeatures, }; // WebGPU Spec: Timestamp Queries Inside Passes // https://github.com/gpuweb/gpuweb/blob/main/proposals/timestamp-query-inside-passes.md if (adapter.features.has('timestamp-query-inside-passes')) { this.supportTimestampQuery = true; - requiredFeatures.push('timestamp-query-inside-passes'); + requiredFeatures.push('timestamp-query-inside-passes' as GPUFeatureName); } if (adapter.features.has('shader-f16')) { requiredFeatures.push('shader-f16'); } - // - // eslint-disable-next-line @typescript-eslint/no-explicit-any - deviceDescriptor.requiredFeatures = requiredFeatures as any; this.device = await adapter.requestDevice(deviceDescriptor); this.gpuDataManager = createGpuDataManager(this); diff --git a/js/web/lib/wasm/jsep/webgpu/ops/common.ts b/js/web/lib/wasm/jsep/webgpu/ops/common.ts index 7f9fd70148284..f3845e3110905 100644 --- a/js/web/lib/wasm/jsep/webgpu/ops/common.ts +++ b/js/web/lib/wasm/jsep/webgpu/ops/common.ts @@ -192,6 +192,10 @@ export interface IndicesHelper { } const getWgslMappedType = (type: number, components: 1|2|3|4): string|[string, string] => { + if (components === 3) { + throw new Error('vec3 has same alignment as vec4, use vec4 instead'); + } + // return type is [ storage type, runtime type ] or a single string for both switch (type) { case DataType.float16: