diff --git a/src/webgpu/api/operation/command_buffer/copyTextureToTexture.spec.ts b/src/webgpu/api/operation/command_buffer/copyTextureToTexture.spec.ts index eb9abfb7d99f..082770504cac 100644 --- a/src/webgpu/api/operation/command_buffer/copyTextureToTexture.spec.ts +++ b/src/webgpu/api/operation/command_buffer/copyTextureToTexture.spec.ts @@ -211,7 +211,7 @@ class F extends TextureTestMixin(GPUTest) { align(dstBlocksPerRow * bytesPerBlock, 4); if (isCompressedTextureFormat(dstTexture.format) && this.isCompatibility) { - assert(viewCompatible(srcFormat, dstFormat)); + assert(viewCompatible(this.isCompatibility, srcFormat, dstFormat)); // compare by rendering. We need the expected texture to match // the dstTexture so we'll create a texture where we supply // all of the data in JavaScript. diff --git a/src/webgpu/api/operation/texture_view/format_reinterpretation.spec.ts b/src/webgpu/api/operation/texture_view/format_reinterpretation.spec.ts index 5683d063c858..f7fb49818eae 100644 --- a/src/webgpu/api/operation/texture_view/format_reinterpretation.spec.ts +++ b/src/webgpu/api/operation/texture_view/format_reinterpretation.spec.ts @@ -100,7 +100,8 @@ g.test('texture_binding') .combine('format', kRegularTextureFormats) .combine('viewFormat', kRegularTextureFormats) .filter( - ({ format, viewFormat }) => format !== viewFormat && viewCompatible(format, viewFormat) + ({ format, viewFormat }) => + format !== viewFormat && viewCompatible(false, format, viewFormat) ) ) .beforeAllSubcases(t => { @@ -202,7 +203,8 @@ in view format and match in base format.` .combine('format', kRenderableColorTextureFormats) .combine('viewFormat', kRenderableColorTextureFormats) .filter( - ({ format, viewFormat }) => format !== viewFormat && viewCompatible(format, viewFormat) + ({ format, viewFormat }) => + format !== viewFormat && viewCompatible(false, format, viewFormat) ) .combine('sampleCount', [1, 4]) ) diff --git a/src/webgpu/api/validation/createTexture.spec.ts b/src/webgpu/api/validation/createTexture.spec.ts index cede60821d0c..dc428846aa26 100644 --- a/src/webgpu/api/validation/createTexture.spec.ts +++ b/src/webgpu/api/validation/createTexture.spec.ts @@ -1105,9 +1105,7 @@ g.test('viewFormats') t.skipIfTextureFormatNotSupported(format, viewFormat); - const compatible = t.isCompatibility - ? viewFormat === format - : viewCompatible(format, viewFormat); + const compatible = viewCompatible(t.isCompatibility, format, viewFormat); // Test the viewFormat in the list. t.expectValidationError(() => { diff --git a/src/webgpu/api/validation/createView.spec.ts b/src/webgpu/api/validation/createView.spec.ts index 768b05cbf75d..3b8bb2d04a02 100644 --- a/src/webgpu/api/validation/createView.spec.ts +++ b/src/webgpu/api/validation/createView.spec.ts @@ -55,10 +55,9 @@ g.test('format') const { blockWidth, blockHeight } = kTextureFormatInfo[textureFormat]; t.skipIfTextureFormatNotSupported(textureFormat, viewFormat); - // Compatibility mode does not support format reinterpretation. - t.skipIf(t.isCompatibility && viewFormat !== undefined && viewFormat !== textureFormat); - const compatible = viewFormat === undefined || viewCompatible(textureFormat, viewFormat); + const compatible = + viewFormat === undefined || viewCompatible(t.isCompatibility, textureFormat, viewFormat); const texture = t.device.createTexture({ format: textureFormat, diff --git a/src/webgpu/format_info.ts b/src/webgpu/format_info.ts index 64ef2cd8956d..a779d2637a6b 100644 --- a/src/webgpu/format_info.ts +++ b/src/webgpu/format_info.ts @@ -1910,8 +1910,12 @@ export function textureDimensionAndFormatCompatible( * * This function may need to be generalized to use `baseFormat` from `kTextureFormatInfo`. */ -export function viewCompatible(a: GPUTextureFormat, b: GPUTextureFormat): boolean { - return a === b || a + '-srgb' === b || b + '-srgb' === a; +export function viewCompatible( + compatibilityMode: boolean, + a: GPUTextureFormat, + b: GPUTextureFormat +): boolean { + return compatibilityMode ? a === b : a === b || a + '-srgb' === b || b + '-srgb' === a; } export function getFeaturesForFormats( diff --git a/src/webgpu/web_platform/canvas/configure.spec.ts b/src/webgpu/web_platform/canvas/configure.spec.ts index 163930e20ef3..71bf45ad1afa 100644 --- a/src/webgpu/web_platform/canvas/configure.spec.ts +++ b/src/webgpu/web_platform/canvas/configure.spec.ts @@ -402,7 +402,7 @@ g.test('viewFormats') const ctx = canvas.getContext('webgpu'); assert(ctx instanceof GPUCanvasContext, 'Failed to get WebGPU context from canvas'); - const compatible = viewCompatible(format, viewFormat); + const compatible = viewCompatible(t.isCompatibility, format, viewFormat); // Test configure() produces an error if the formats aren't compatible. t.expectValidationError(() => {