From 015cf9976a370151049f404a3362b77b3ac71534 Mon Sep 17 00:00:00 2001 From: Greggman Date: Thu, 16 Jan 2025 03:35:09 +0900 Subject: [PATCH 1/2] Fix mem-sync same_subresource tests for 0 storage buffers. (#4147) --- .../memory_sync/texture/same_subresource.spec.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/webgpu/api/operation/memory_sync/texture/same_subresource.spec.ts b/src/webgpu/api/operation/memory_sync/texture/same_subresource.spec.ts index eef4f81680e..c2e3c17fbd3 100644 --- a/src/webgpu/api/operation/memory_sync/texture/same_subresource.spec.ts +++ b/src/webgpu/api/operation/memory_sync/texture/same_subresource.spec.ts @@ -65,6 +65,12 @@ function writeOpNeedsStorageTexture({ op, in: context }: { op: Op; in: Operation ); } +function getVisibilityForContext(context: OperationContext) { + return context === 'render-bundle-encoder' || context === 'render-pass-encoder' + ? GPUShaderStage.FRAGMENT + : GPUShaderStage.COMPUTE; +} + class TextureSyncTestHelper extends OperationContextHelper { private texture: GPUTexture; @@ -169,19 +175,19 @@ class TextureSyncTestHelper extends OperationContextHelper { format: this.kTextureFormat, usage: GPUTextureUsage.COPY_SRC | GPUTextureUsage.STORAGE_BINDING, }); - + const visibility = getVisibilityForContext(context); const bindGroupLayout = this.device.createBindGroupLayout({ entries: [ { binding: 0, - visibility: GPUShaderStage.FRAGMENT | GPUShaderStage.COMPUTE, + visibility, texture: { sampleType: 'unfilterable-float', }, }, { binding: 1, - visibility: GPUShaderStage.FRAGMENT | GPUShaderStage.COMPUTE, + visibility, storageTexture: { access: 'write-only', format: this.kTextureFormat, @@ -440,11 +446,12 @@ class TextureSyncTestHelper extends OperationContextHelper { break; } case 'storage': { + const visibility = getVisibilityForContext(context); const bindGroupLayout = this.device.createBindGroupLayout({ entries: [ { binding: 0, - visibility: GPUShaderStage.FRAGMENT | GPUShaderStage.COMPUTE, + visibility, storageTexture: { access: 'write-only', format: this.kTextureFormat, From f7421c6a74451923af5e198d45417d486dcb82b9 Mon Sep 17 00:00:00 2001 From: Greggman Date: Thu, 16 Jan 2025 06:20:30 +0900 Subject: [PATCH 2/2] Compat: Fix canvas configure test for 0 storagebuffers (#4146) --- src/webgpu/web_platform/canvas/configure.spec.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/webgpu/web_platform/canvas/configure.spec.ts b/src/webgpu/web_platform/canvas/configure.spec.ts index 3e9905dd5bd..69e058d8d1a 100644 --- a/src/webgpu/web_platform/canvas/configure.spec.ts +++ b/src/webgpu/web_platform/canvas/configure.spec.ts @@ -16,10 +16,10 @@ import { filterFormatsByFeature, viewCompatible, } from '../../format_info.js'; -import { GPUTest } from '../../gpu_test.js'; +import { GPUTest, MaxLimitsTestMixin } from '../../gpu_test.js'; import { kAllCanvasTypes, createCanvas } from '../../util/create_elements.js'; -export const g = makeTestGroup(GPUTest); +export const g = makeTestGroup(MaxLimitsTestMixin(GPUTest)); g.test('defaults') .desc( @@ -212,6 +212,7 @@ g.test('usage') ) .fn(t => { const { canvasType, usage } = t.params; + const canvas = createCanvas(t, canvasType, 2, 2); const ctx = canvas.getContext('webgpu'); assert(ctx instanceof GPUCanvasContext, 'Failed to get WebGPU context from canvas'); @@ -269,7 +270,13 @@ g.test('usage') }); } - if (usage & GPUConst.TextureUsage.STORAGE_BINDING) { + const canUseStorageTextureInFragmentShader = + !t.isCompatibility || t.device.limits.maxStorageTexturesInFragmentStage! > 0; + + if ( + (usage & GPUConst.TextureUsage.STORAGE_BINDING) !== 0 && + canUseStorageTextureInFragmentShader + ) { const bgl = t.device.createBindGroupLayout({ entries: [ {