Skip to content

Commit

Permalink
Fix refactors (#4215)
Browse files Browse the repository at this point in the history
A few bugs made it through on the refactors.
  • Loading branch information
greggman authored Feb 25, 2025
1 parent 3d17e72 commit a408852
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
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

0 comments on commit a408852

Please sign in to comment.