Skip to content

Commit e34f99a

Browse files
Clean unnecessary swizzle related casts (#4473)
1 parent e6c5ee9 commit e34f99a

File tree

7 files changed

+17
-30
lines changed

7 files changed

+17
-30
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"@types/w3c-image-capture": "^1.0.10",
5151
"@typescript-eslint/eslint-plugin": "^6.9.1",
5252
"@typescript-eslint/parser": "^6.9.1",
53-
"@webgpu/types": "^0.1.64",
53+
"@webgpu/types": "^0.1.66",
5454
"ansi-colors": "4.1.3",
5555
"babel-plugin-add-header-comment": "^1.0.3",
5656
"babel-plugin-const-enum": "^1.2.0",

src/webgpu/api/operation/texture_view/texture_component_swizzle.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,7 @@ g.test('read_swizzle')
254254
.combine('otherSwizzleIndexOffset', [0, 1, 5]) // used to choose a different 2nd swizzle. 0 = same swizzle as 1st
255255
)
256256
.fn(async t => {
257-
// MAINTENANCE_TODO: Remove this cast once texture-component-swizzle is added to @webgpu/types
258-
t.skipIfDeviceDoesNotHaveFeature('texture-component-swizzle' as GPUFeatureName);
257+
t.skipIfDeviceDoesNotHaveFeature('texture-component-swizzle');
259258
const { format, func, channel, compare, input, aspect, swizzle, otherSwizzleIndexOffset } =
260259
t.params;
261260
t.skipIfTextureFormatNotSupported(format);

src/webgpu/api/validation/capability_checks/features/texture_component_swizzle.spec.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ g.test('invalid_swizzle')
5454
])
5555
)
5656
.beforeAllSubcases(t => {
57-
// MAINTENANCE_TODO: Remove this cast once texture-component-swizzle is added to @webgpu/types
58-
t.selectDeviceOrSkipTestCase('texture-component-swizzle' as GPUFeatureName);
57+
t.selectDeviceOrSkipTestCase('texture-component-swizzle');
5958
})
6059
.fn(t => {
6160
const { invalidSwizzle } = t.params;
@@ -79,12 +78,6 @@ g.test('only_identity_swizzle')
7978
)
8079
.params(u => u.beginSubcases().combine('swizzle', kSwizzleTests))
8180
.fn(t => {
82-
// MAINTENANCE_TODO: Remove this check if the spec is updated to say that all implementations must validate this.
83-
t.skipIf(
84-
!t.adapter.features.has('texture-component-swizzle'),
85-
'skip on browsers that have not implemented texture-component-swizzle'
86-
);
87-
8881
const { swizzle } = t.params;
8982
const texture = t.createTextureTracked({
9083
format: 'rgba8unorm',
@@ -118,8 +111,7 @@ g.test('no_render_no_resolve_no_storage')
118111
.combine('swizzle', kSwizzleTests)
119112
)
120113
.beforeAllSubcases(t => {
121-
// MAINTENANCE_TODO: Remove this cast once texture-component-swizzle is added to @webgpu/types
122-
t.selectDeviceOrSkipTestCase('texture-component-swizzle' as GPUFeatureName);
114+
t.selectDeviceOrSkipTestCase('texture-component-swizzle');
123115
})
124116
.fn(t => {
125117
const { swizzle, useCase } = t.params;
@@ -264,8 +256,7 @@ g.test('compatibility_mode')
264256
`
265257
)
266258
.beforeAllSubcases(t => {
267-
// MAINTENANCE_TODO: Remove this cast once texture-component-swizzle is added to @webgpu/types
268-
t.selectDeviceOrSkipTestCase('texture-component-swizzle' as GPUFeatureName);
259+
t.selectDeviceOrSkipTestCase('texture-component-swizzle');
269260
})
270261
.params(u =>
271262
u

src/webgpu/api/validation/capability_checks/features/texture_component_swizzle_utils.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ declare global {
55

66
// Note this is a four-character string that only includes `"r"`, `"g"`, `"b"`, `"a"`, `"0"`, or `"1"`.
77
type GPUTextureComponentSwizzle = string;
8-
9-
// MAINTENANCE_TODO: Remove these types once texture-component-swizzle is added to @webgpu/types
10-
/* prettier-ignore */
11-
interface GPUTextureViewDescriptor {
12-
swizzle?: GPUTextureComponentSwizzle; // "rgba" by default
13-
}
148
}
159

1610
// Note: There are 4 settings with 6 options which is 1296 combinations. So we don't check them all. Just a few below.

src/webgpu/capability_info.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,8 @@ export const kFeatureNameInfo: {
924924
'core-features-and-limits': {},
925925
'texture-formats-tier1': {},
926926
'texture-formats-tier2': {},
927+
'primitive-index': {},
928+
'texture-component-swizzle': {},
927929
};
928930
/** List of all GPUFeatureName values. */
929931
export const kFeatureNames = keysOf(kFeatureNameInfo);

src/webgpu/util/texture/base.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,15 @@ export function reifyTextureDescriptor(
216216
export function reifyTextureViewDescriptor(
217217
textureDescriptor: Readonly<GPUTextureDescriptor>,
218218
view: Readonly<GPUTextureViewDescriptor>
219-
// MAINTENANCE_TODO: Remove | swizzle cast once texture-component-swizzle is added to @webgpu/types
220-
): Required<Omit<GPUTextureViewDescriptor, 'label' | 'swizzle'>> {
219+
): Required<Omit<GPUTextureViewDescriptor, 'label'>> {
221220
const texture = reifyTextureDescriptor(textureDescriptor);
222221

223222
// IDL defaulting
224223

225224
const baseMipLevel = view.baseMipLevel ?? 0;
226225
const baseArrayLayer = view.baseArrayLayer ?? 0;
227226
const aspect = view.aspect ?? 'all';
227+
const swizzle = view.swizzle ?? 'rgba';
228228

229229
// Spec defaulting
230230

@@ -253,6 +253,7 @@ export function reifyTextureViewDescriptor(
253253
mipLevelCount,
254254
baseArrayLayer,
255255
arrayLayerCount,
256+
swizzle,
256257
};
257258
}
258259

0 commit comments

Comments
 (0)