Skip to content

Commit

Permalink
Compat: fix float16(32)-renderable tests (web_platform) (gpuweb#4161)
Browse files Browse the repository at this point in the history
  • Loading branch information
shrekshao authored Jan 24, 2025
1 parent 1e8a378 commit e1a5ecf
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/webgpu/web_platform/canvas/configure.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ g.test('format')
)
.beforeAllSubcases(t => {
t.selectDeviceForTextureFormatOrSkipTestCase(t.params.format);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.format);
})
.fn(t => {
const { canvasType, format } = t.params;
Expand Down Expand Up @@ -446,6 +447,7 @@ g.test('viewFormats')
)
)
.beforeAllSubcases(t => {
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.format);
t.selectDeviceOrSkipTestCase([t.params.viewFormatFeature]);
})
.fn(t => {
Expand Down
16 changes: 16 additions & 0 deletions src/webgpu/web_platform/canvas/readbackFromWebGPUCanvas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ g.test('onscreenCanvas,snapshot')
.combine('colorSpace', kCanvasColorSpaces)
.combine('snapshotType', ['toDataURL', 'toBlob', 'imageBitmap'])
)
.beforeAllSubcases(t => {
// rgba16float may not be color-renderable in compat mode
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.format);
})
.fn(async t => {
const canvas = initWebGPUCanvasContent(
t,
Expand Down Expand Up @@ -323,6 +327,10 @@ g.test('offscreenCanvas,snapshot')
.combine('colorSpace', kCanvasColorSpaces)
.combine('snapshotType', ['convertToBlob', 'transferToImageBitmap', 'imageBitmap'] as const)
)
.beforeAllSubcases(t => {
// rgba16float may not be color-renderable in compat mode
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.format);
})
.fn(async t => {
const offscreenCanvas = initWebGPUCanvasContent(
t,
Expand Down Expand Up @@ -378,6 +386,10 @@ g.test('onscreenCanvas,uploadToWebGL')
.combine('webgl', ['webgl', 'webgl2'])
.combine('upload', ['texImage2D', 'texSubImage2D'])
)
.beforeAllSubcases(t => {
// rgba16float may not be color-renderable in compat mode
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.format);
})
.fn(t => {
const { format, webgl, upload } = t.params;
const canvas = initWebGPUCanvasContent(t, format, t.params.alphaMode, 'srgb', 'onscreen');
Expand Down Expand Up @@ -459,6 +471,10 @@ g.test('drawTo2DCanvas')
.combine('webgpuCanvasType', kAllCanvasTypes)
.combine('canvas2DType', kAllCanvasTypes)
)
.beforeAllSubcases(t => {
// rgba16float may not be color-renderable in compat mode
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.format);
})
.fn(t => {
const { format, webgpuCanvasType, alphaMode, colorSpace, canvas2DType } = t.params;

Expand Down
2 changes: 2 additions & 0 deletions src/webgpu/web_platform/copyToTexture/ImageBitmap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ g.test('from_ImageData')
.beforeAllSubcases(t => {
t.skipIf(typeof ImageData === 'undefined', 'ImageData does not exist in this environment');
t.skipIfTextureFormatNotSupported(t.params.dstFormat);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.dstFormat);
})
.fn(async t => {
const {
Expand Down Expand Up @@ -182,6 +183,7 @@ g.test('from_canvas')
.beforeAllSubcases(t => {
t.skipIf(typeof ImageData === 'undefined', 'ImageData does not exist in this environment');
t.skipIfTextureFormatNotSupported(t.params.dstFormat);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.dstFormat);
})
.fn(async t => {
const {
Expand Down
1 change: 1 addition & 0 deletions src/webgpu/web_platform/copyToTexture/ImageData.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ g.test('from_ImageData')
.beforeAllSubcases(t => {
t.skipIf(typeof ImageData === 'undefined', 'ImageData does not exist in this environment');
t.skipIfTextureFormatNotSupported(t.params.dstColorFormat);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.dstColorFormat);
})
.fn(t => {
const { width, height, dstColorFormat, dstPremultiplied, srcDoFlipYDuringCopy } = t.params;
Expand Down
5 changes: 5 additions & 0 deletions src/webgpu/web_platform/copyToTexture/canvas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ g.test('copy_contents_from_2d_context_canvas')
)
.beforeAllSubcases(t => {
t.skipIfTextureFormatNotSupported(t.params.dstColorFormat);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.dstColorFormat);
})
.fn(t => {
const { width, height, canvasType, dstAlphaMode } = t.params;
Expand Down Expand Up @@ -559,6 +560,7 @@ g.test('copy_contents_from_gl_context_canvas')
)
.beforeAllSubcases(t => {
t.skipIfTextureFormatNotSupported(t.params.dstColorFormat);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.dstColorFormat);
})
.fn(t => {
const { width, height, canvasType, contextName, srcPremultiplied, dstAlphaMode } = t.params;
Expand Down Expand Up @@ -628,6 +630,7 @@ g.test('copy_contents_from_gpu_context_canvas')
)
.beforeAllSubcases(t => {
t.skipIfTextureFormatNotSupported(t.params.dstColorFormat);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.dstColorFormat);
t.selectMismatchedDeviceOrSkipTestCase(undefined);
})
.fn(t => {
Expand Down Expand Up @@ -694,6 +697,7 @@ g.test('copy_contents_from_bitmaprenderer_context_canvas')
)
.beforeAllSubcases(t => {
t.skipIfTextureFormatNotSupported(t.params.dstColorFormat);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.dstColorFormat);
})
.fn(async t => {
const { width, height, canvasType, dstAlphaMode } = t.params;
Expand Down Expand Up @@ -770,6 +774,7 @@ g.test('color_space_conversion')
)
.beforeAllSubcases(t => {
t.skipIfTextureFormatNotSupported(t.params.dstColorFormat);
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.dstColorFormat);
})
.fn(t => {
const {
Expand Down
1 change: 1 addition & 0 deletions src/webgpu/web_platform/copyToTexture/image.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ g.test('from_image')
.beforeAllSubcases(t => {
t.skipIfTextureFormatNotSupported(t.params.dstColorFormat);
if (typeof HTMLImageElement === 'undefined') t.skip('HTMLImageElement not available');
t.selectDeviceForRenderableColorFormatOrSkipTestCase(t.params.dstColorFormat);
})
.fn(async t => {
const { width, height, dstColorFormat, dstPremultiplied, srcDoFlipYDuringCopy } = t.params;
Expand Down

0 comments on commit e1a5ecf

Please sign in to comment.