Skip to content

Commit 74527ce

Browse files
authored
Remove deprecated from gpu_test.ts/format_info.ts (#4286)
And make `kTextureFormatInfo` private. Note: I didn't remove 100% of things labeled deprecated in gpu_test.ts. I'll save the few remaining for a future PR.
1 parent 336b847 commit 74527ce

File tree

3 files changed

+84
-193
lines changed

3 files changed

+84
-193
lines changed

src/webgpu/format_info.ts

+69-49
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// MAINTENANCE_TODO: Remove all deprecated functions once they are no longer in use.
21
import { isCompatibilityDevice } from '../common/framework/test_config.js';
32
import { keysOf } from '../common/util/data_tables.js';
43
import { assert, unreachable } from '../common/util/util.js';
@@ -1518,13 +1517,75 @@ type TextureFormatInfo_TypeCheck = {
15181517
)
15191518
);
15201519

1521-
// MAINTENANCE_TODO: make this private to avoid tests wrongly trying to
1522-
// filter things on their own. Various features make this hard to do correctly
1523-
// so we'd prefer to put filtering here, in a central place and add other functions
1524-
// to get at this data so that they always have enough info to give the correct answer.
1525-
/** Per-GPUTextureFormat info. */
1526-
/** @deprecated */
1527-
export const kTextureFormatInfo = {
1520+
/**
1521+
* DO NOT EXPORT THIS - functions that need info from this table should use the appropriate
1522+
* method for their needs.
1523+
*
1524+
* For a list of textures formats for test parameters there are:
1525+
*
1526+
* Lists of formats that might require features to be enabled
1527+
* * kPossibleColorRenderableTextureFormats
1528+
* * kPossibleStorageTextureFormats
1529+
* * kPossibleReadWriteStorageTextureFormats
1530+
* * kPossibleMultisampledTextureFormats
1531+
*
1532+
* Lists of formats that end in -srgb
1533+
* * kDifferentBaseFormatTextureFormats (includes compressed textures)
1534+
* * kDifferentBaseFormatRegularTextureFormats (does not include compressed textures)
1535+
*
1536+
* Formats that require a feature to use at all (mostly compressed formats)
1537+
* * kOptionalTextureFormats
1538+
*
1539+
* Misc
1540+
* * kRegularTextureFormats
1541+
* * kSizedDepthStencilFormats
1542+
* * kUnsizedDepthStencilFormats
1543+
* * kCompressedTextureFormats
1544+
* * kUncompressedTextureFormats
1545+
* * kColorTextureFormats - color formats including compressed and sint/uint
1546+
* * kEncodableTextureFormats - formats that TexelView supports.
1547+
* * kSizedTextureFormats - formats that have a known size (so not depth24plus ...)
1548+
* * kDepthStencilFormats - depth, stencil, depth-stencil
1549+
* * kDepthTextureFormats - depth and depth-stencil
1550+
* * kStencilTextureFormats - stencil and depth-stencil
1551+
* * kAllTextureFormats
1552+
*
1553+
* If one of the list above does not work, add a new one or to filter in beforeAllSubcases you generally want to use
1554+
* You will not know if you can actually use a texture for the given use case until the test runs and has a device.
1555+
*
1556+
* * isTextureFormatPossiblyUsableAsRenderAttachment
1557+
* * isTextureFormatPossiblyUsableAsColorRenderAttachment
1558+
* * isTextureFormatPossiblyMultisampled
1559+
* * isTextureFormatPossiblyStorageReadable
1560+
* * isTextureFormatPossiblyStorageReadWritable
1561+
* * isTextureFormatPossiblyFilterableAsTextureF32
1562+
*
1563+
* These are also usable before or during a test
1564+
*
1565+
* * isColorTextureFormat
1566+
* * isDepthTextureFormat
1567+
* * isStencilTextureFormat
1568+
* * isDepthOrStencilTextureFormat
1569+
* * isEncodableTextureFormat
1570+
* * isRegularTextureFormat
1571+
* * isCompressedFloatTextureFormat
1572+
* * isSintOrUintFormat
1573+
*
1574+
* To skip a test use the `skipIfXXX` tests in `GPUTest` if possible. Otherwise these functions
1575+
* require a device to give a correct answer.
1576+
*
1577+
* * isTextureFormatUsableAsRenderAttachment
1578+
* * isTextureFormatColorRenderable
1579+
* * isTextureFormatResolvable
1580+
* * isTextureFormatBlendable
1581+
* * isTextureFormatMultisampled
1582+
* * isTextureFormatUsableAsStorageFormat
1583+
* * isTextureFormatUsableAsReadWriteStorageTexture
1584+
* * isTextureFormatUsableAsStorageFormatInCreateShaderModule
1585+
*
1586+
* Per-GPUTextureFormat info.
1587+
*/
1588+
const kTextureFormatInfo = {
15281589
...kRegularTextureFormatInfo,
15291590
...kSizedDepthStencilFormatInfo,
15301591
...kUnsizedDepthStencilFormatInfo,
@@ -1801,15 +1862,6 @@ export function textureDimensionAndFormatCompatible(
18011862
);
18021863
}
18031864

1804-
/** @deprecated */
1805-
export function viewCompatibleDeprecated(
1806-
compatibilityMode: boolean,
1807-
a: GPUTextureFormat,
1808-
b: GPUTextureFormat
1809-
): boolean {
1810-
return compatibilityMode ? a === b : a === b || a + '-srgb' === b || b + '-srgb' === a;
1811-
}
1812-
18131865
/**
18141866
* Check if two formats are view format compatible.
18151867
*/
@@ -2039,11 +2091,6 @@ export function isEncodableTextureFormat(format: GPUTextureFormat) {
20392091
return kEncodableTextureFormats.includes(format as EncodableTextureFormat);
20402092
}
20412093

2042-
/** @deprecated use isTextureFormatUsableAsRenderAttachment */
2043-
export function canUseAsRenderTargetDeprecated(format: GPUTextureFormat) {
2044-
return kTextureFormatInfo[format].colorRender || isDepthOrStencilTextureFormat(format);
2045-
}
2046-
20472094
/**
20482095
* Returns if a texture can be used as a render attachment. some color formats and all
20492096
* depth textures and stencil textures are usable with usage RENDER_ATTACHMENT.
@@ -2177,20 +2224,6 @@ export const kCompatModeUnsupportedStorageTextureFormats: readonly GPUTextureFor
21772224
'rg32uint',
21782225
] as const;
21792226

2180-
/** @deprecated */
2181-
export function isTextureFormatUsableAsStorageFormatDeprecated(
2182-
format: GPUTextureFormat,
2183-
isCompatibilityMode: boolean
2184-
): boolean {
2185-
if (isCompatibilityMode) {
2186-
if (kCompatModeUnsupportedStorageTextureFormats.indexOf(format) >= 0) {
2187-
return false;
2188-
}
2189-
}
2190-
const info = kTextureFormatInfo[format];
2191-
return !!(info.color?.storage || info.depth?.storage || info.stencil?.storage);
2192-
}
2193-
21942227
/**
21952228
* Return true if the format can be used as a storage texture.
21962229
* Note: Some formats can be compiled in a shader but can not be used
@@ -2285,19 +2318,6 @@ export const kCompatModeUnsupportedMultisampledTextureFormats: readonly GPUTextu
22852318
'r32float',
22862319
] as const;
22872320

2288-
/** @deprecated use isTextureFormatMultisampled */
2289-
export function isMultisampledTextureFormatDeprecated(
2290-
format: GPUTextureFormat,
2291-
isCompatibilityMode: boolean
2292-
): boolean {
2293-
if (isCompatibilityMode) {
2294-
if (kCompatModeUnsupportedMultisampledTextureFormats.indexOf(format) >= 0) {
2295-
return false;
2296-
}
2297-
}
2298-
return kAllTextureFormatInfo[format].multisample;
2299-
}
2300-
23012321
/**
23022322
* Returns true if you can make a multisampled texture from the given format.
23032323
*/

0 commit comments

Comments
 (0)