Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix refactors #4215

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class F extends TextureTestMixin(AllFeaturesMaxLimitsGPUTest) {
srcCopyLevel: number,
dstCopyLevel: number
): void {
this.skipIfTextureFormatNotSupportedDeprecated(srcFormat, dstFormat);
this.skipIfTextureFormatNotSupported(srcFormat, dstFormat);

// If we're in compatibility mode and it's a compressed texture
// then we need to render the texture to test the results of the copy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ g.test('blending,formats')
.fn(t => {
const { format } = t.params;
t.skipIfTextureFormatNotSupported(format);
t.skipIfTextureFormatNotUsableAsRenderAttachment(format);
t.skipIfTextureFormatNotBlendable(format);

const pipeline = t.device.createRenderPipeline({
Expand Down
5 changes: 3 additions & 2 deletions src/webgpu/api/operation/rendering/depth_clip_clamp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ depth ranges as well.

import { makeTestGroup } from '../../../../common/framework/test_group.js';
import {
canCopyFromAspectOfTextureFormat,
getBlockInfoForTextureFormat,
isStencilTextureFormat,
kDepthTextureFormats,
Expand Down Expand Up @@ -231,14 +232,14 @@ have unexpected values then get drawn to the color buffer, which is later checke

const { bytesPerBlock } = getBlockInfoForTextureFormat(format);
const dsActual =
!multisampled && bytesPerBlock
canCopyFromAspectOfTextureFormat(format, 'depth-only') && !multisampled && bytesPerBlock
? t.createBufferTracked({
size: kNumTestPoints * bytesPerBlock,
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ,
})
: undefined;
const dsExpected =
!multisampled && bytesPerBlock
canCopyFromAspectOfTextureFormat(format, 'depth-only') && !multisampled && bytesPerBlock
? t.createBufferTracked({
size: kNumTestPoints * bytesPerBlock,
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ,
Expand Down
39 changes: 39 additions & 0 deletions src/webgpu/format_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1902,6 +1902,45 @@ export function filterFormatsByFeature<T>(
return formats.filter(f => f === undefined || kTextureFormatInfo[f].feature === feature);
}

export function canCopyToAspectOfTextureFormat(format: GPUTextureFormat, aspect: GPUTextureAspect) {
const info = kTextureFormatInfo[format];
switch (aspect) {
case 'depth-only':
assert(isDepthTextureFormat(format));
return info.depth && info.depth.copyDst;
case 'stencil-only':
assert(isStencilTextureFormat(format));
return info.stencil && info.stencil.copyDst;
case 'all':
return (
(!isDepthTextureFormat(format) || info.depth?.copyDst) &&
(!isStencilTextureFormat(format) || info.stencil?.copyDst) &&
(!isColorTextureFormat(format) || !info.color?.copyDst)
);
}
}

export function canCopyFromAspectOfTextureFormat(
format: GPUTextureFormat,
aspect: GPUTextureAspect
) {
const info = kTextureFormatInfo[format];
switch (aspect) {
case 'depth-only':
assert(isDepthTextureFormat(format));
return info.depth && info.depth.copySrc;
case 'stencil-only':
assert(isStencilTextureFormat(format));
return info.stencil && info.stencil.copySrc;
case 'all':
return (
(!isDepthTextureFormat(format) || info.depth?.copySrc) &&
(!isStencilTextureFormat(format) || info.stencil?.copySrc) &&
(!isColorTextureFormat(format) || !info.color?.copySrc)
);
}
}

export function canCopyAllAspectsOfTextureFormat(format: GPUTextureFormat) {
const info = kTextureFormatInfo[format];
return (
Expand Down