Skip to content

Commit

Permalink
Add unit tests for resolvePerAspectFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
kainino0x committed Mar 12, 2024
1 parent cc2dfd6 commit c5a2ecf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 34 additions & 0 deletions src/webgpu/format_info.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export const description = `
Unittests for helpers in format_info.ts.
`;

import { Fixture } from '../common/framework/fixture.js';
import { makeTestGroup } from '../common/framework/test_group.js';
import { assert, objectEquals } from '../common/util/util.js';

import { kDepthStencilFormats, kTextureFormatInfo, resolvePerAspectFormat } from './format_info.js';

export const g = makeTestGroup(Fixture);

g.test('resolvePerAspectFormat')
.desc(
`Test that resolvePerAspectFormat works and kTextureFormatInfo contains identical
information for the combined and separate versions of that aspect.`
)
.fn(t => {
for (const format of kDepthStencilFormats) {
const info = kTextureFormatInfo[format];
if (info.depth) {
const depthFormatInfo = kTextureFormatInfo[resolvePerAspectFormat(format, 'depth-only')];
assert(objectEquals(info.depth, depthFormatInfo.depth), 'Error in texture format table');
}
if (info.stencil) {
const stencilFormatInfo =
kTextureFormatInfo[resolvePerAspectFormat(format, 'stencil-only')];
assert(
objectEquals(info.stencil, stencilFormatInfo.stencil),
'Error in texture format table'
);
}
}
});
2 changes: 1 addition & 1 deletion src/webgpu/format_info.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { keysOf } from '../common/util/data_tables.js';
import { assert, unreachable } from '../common/util/util.js';
import { assert, objectEquals, unreachable } from '../common/util/util.js';

import { align } from './util/math.js';
import { ImageCopyType } from './util/texture/layout.js';
Expand Down

0 comments on commit c5a2ecf

Please sign in to comment.