From 7a0291ce726aedf128fce78e533610c37ed35fba Mon Sep 17 00:00:00 2001 From: Geoff Lang Date: Wed, 25 Sep 2024 15:50:36 -0400 Subject: [PATCH] Formatting. --- .../api/operation/texture_view/write.spec.ts | 35 +++++------ src/webgpu/api/validation/createView.spec.ts | 18 +++--- .../texture/in_render_misc.spec.ts | 62 +++++++++---------- 3 files changed, 54 insertions(+), 61 deletions(-) diff --git a/src/webgpu/api/operation/texture_view/write.spec.ts b/src/webgpu/api/operation/texture_view/write.spec.ts index 60b3e5746220..828e7518ba5a 100644 --- a/src/webgpu/api/operation/texture_view/write.spec.ts +++ b/src/webgpu/api/operation/texture_view/write.spec.ts @@ -36,10 +36,7 @@ const kTextureViewWriteMethods = [ ] as const; type TextureViewWriteMethod = (typeof kTextureViewWriteMethods)[number]; -const kTextureViewUsageMethods = [ - 'inherit', - 'minimal', -] as const; +const kTextureViewUsageMethods = ['inherit', 'minimal'] as const; type TextureViewUsageMethod = (typeof kTextureViewUsageMethods)[number]; // Src color values to read from a shader array. @@ -278,18 +275,19 @@ function writeTextureAndGetExpectedTexelView( } function getTextureViewUsage( - viewUsageMethod : TextureViewUsageMethod, - minimalUsageForTest : GPUTextureUsageFlags) { - switch (viewUsageMethod) { - case 'inherit': - return 0; + viewUsageMethod: TextureViewUsageMethod, + minimalUsageForTest: GPUTextureUsageFlags +) { + switch (viewUsageMethod) { + case 'inherit': + return 0; - case 'minimal': - return minimalUsageForTest; + case 'minimal': + return minimalUsageForTest; - default: - unreachable(); - } + default: + unreachable(); + } } g.test('format') @@ -358,10 +356,9 @@ TODO: Test rgb10a2uint when TexelRepresentation.numericRange is made per-compone const { format, method, sampleCount, viewUsageMethod } = t.params; const textureUsageForMethod = method.includes('storage') - ? GPUTextureUsage.STORAGE_BINDING - : GPUTextureUsage.RENDER_ATTACHMENT; - const usage = - GPUTextureUsage.COPY_SRC | textureUsageForMethod; + ? GPUTextureUsage.STORAGE_BINDING + : GPUTextureUsage.RENDER_ATTACHMENT; + const usage = GPUTextureUsage.COPY_SRC | textureUsageForMethod; const texture = t.createTextureTracked({ format, @@ -371,7 +368,7 @@ TODO: Test rgb10a2uint when TexelRepresentation.numericRange is made per-compone }); const view = texture.createView({ - usage : getTextureViewUsage(viewUsageMethod, textureUsageForMethod), + usage: getTextureViewUsage(viewUsageMethod, textureUsageForMethod), }); const expectedTexelView = writeTextureAndGetExpectedTexelView( t, diff --git a/src/webgpu/api/validation/createView.spec.ts b/src/webgpu/api/validation/createView.spec.ts index bbab07af2922..4eab2a7b4e36 100644 --- a/src/webgpu/api/validation/createView.spec.ts +++ b/src/webgpu/api/validation/createView.spec.ts @@ -363,7 +363,7 @@ g.test('texture_view_usage') if (textureUsage & GPUTextureUsage.STORAGE_BINDING) { t.skipIfTextureFormatNotUsableAsStorageTexture(format); } - if ((textureUsage & GPUTextureUsage.RENDER_ATTACHMENT) && info.color && !info.colorRender) { + if (textureUsage & GPUTextureUsage.RENDER_ATTACHMENT && info.color && !info.colorRender) { t.skip(`Texture with ${format} is not usable as a render attachment`); } }) @@ -374,9 +374,9 @@ g.test('texture_view_usage') const size = [info.blockWidth, info.blockHeight, 1]; const dimension = '2d'; const mipLevelCount = 1; - const usage = textureUsage0 | textureUsage0; + const usage = textureUsage0 | textureUsage1; - const textureDescriptor : GPUTextureDescriptor = { + const textureDescriptor: GPUTextureDescriptor = { size, mipLevelCount, dimension, @@ -391,11 +391,11 @@ g.test('texture_view_usage') const textureViewUsage = textureViewUsage0 | textureViewUsage1; // Texture view usage must be a subset of texture usage - if ((~usage & textureViewUsage) != 0) success = false; + if ((~usage & textureViewUsage) !== 0) success = false; - t.expectValidationError(() => { - texture.createView({ - usage : textureViewUsage, - }); - }, !success); + t.expectValidationError(() => { + texture.createView({ + usage: textureViewUsage, + }); + }, !success); }); diff --git a/src/webgpu/api/validation/resource_usages/texture/in_render_misc.spec.ts b/src/webgpu/api/validation/resource_usages/texture/in_render_misc.spec.ts index 75a2d3084bf0..6852335e9a71 100644 --- a/src/webgpu/api/validation/resource_usages/texture/in_render_misc.spec.ts +++ b/src/webgpu/api/validation/resource_usages/texture/in_render_misc.spec.ts @@ -4,15 +4,13 @@ Texture Usages Validation Tests on All Kinds of WebGPU Subresource Usage Scopes. import { makeTestGroup } from '../../../../../common/framework/test_group.js'; import { unreachable } from '../../../../../common/util/util.js'; +import { kTextureUsages } from '../../../../capability_info.js'; import { ValidationTest } from '../../validation_test.js'; import { TextureBindingType, kTextureBindingTypes, IsReadOnlyTextureBindingType, } from '../texture/in_render_common.spec.js'; -import { - kTextureUsages, -} from '../../../../capability_info.js'; class F extends ValidationTest { createBindGroupLayoutForTest( @@ -583,10 +581,7 @@ g.test('subresources,texture_view_usages') ) .params(u => u - .combine('usage', [ - 'color-attachment', - ...kTextureBindingTypes, - ] as const) + .combine('usage', ['color-attachment', ...kTextureBindingTypes] as const) .combine('viewUsage', [0, ...kTextureUsages]) ) .fn(t => { @@ -606,17 +601,17 @@ g.test('subresources,texture_view_usages') }), }); - - let validViewUsage = 0; switch (usage) { case 'color-attachment': { const encoder = t.device.createCommandEncoder(); const renderPassEncoder = encoder.beginRenderPass({ - colorAttachments: [{ view: texture.createView({usage:viewUsage}), loadOp: 'load', storeOp: 'store' }], + colorAttachments: [ + { view: texture.createView({ usage: viewUsage }), loadOp: 'load', storeOp: 'store' }, + ], }); renderPassEncoder.end(); - const success = (viewUsage == 0) || (viewUsage & GPUTextureUsage.RENDER_ATTACHMENT); + const success = viewUsage === 0 || viewUsage & GPUTextureUsage.RENDER_ATTACHMENT; t.expectValidationError(() => { encoder.finish(); @@ -626,29 +621,30 @@ g.test('subresources,texture_view_usages') case 'sampled-texture': case 'readonly-storage-texture': case 'writeonly-storage-texture': - case 'readwrite-storage-texture': { - let success = true; - if (viewUsage != 0) { - if (usage == 'sampled-texture') { - if ((viewUsage & GPUTextureUsage.TEXTURE_BINDING) == 0) success = false; - } else { - if ((viewUsage & GPUTextureUsage.STORAGE_BINDING) == 0) success = false; + case 'readwrite-storage-texture': + { + let success = true; + if (viewUsage !== 0) { + if (usage === 'sampled-texture') { + if ((viewUsage & GPUTextureUsage.TEXTURE_BINDING) === 0) success = false; + } else { + if ((viewUsage & GPUTextureUsage.STORAGE_BINDING) === 0) success = false; + } } - } - t.expectValidationError(() => { - const bindGroup = t.createBindGroupForTest( - texture.createView({ - dimension: '2d-array', - usage:viewUsage - }), - usage, - 'unfilterable-float' - ); - }, !success); - } - break; - default: - unreachable(); + t.expectValidationError(() => { + t.createBindGroupForTest( + texture.createView({ + dimension: '2d-array', + usage: viewUsage, + }), + usage, + 'unfilterable-float' + ); + }, !success); + } + break; + default: + unreachable(); } });