Skip to content
Open
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
71 changes: 70 additions & 1 deletion src/webgpu/api/operation/reflection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Tests that object attributes which reflect the object's creation properties are

import { makeTestGroup } from '../../../common/framework/test_group.js';
import { GPUConst } from '../../constants.js';
import { AllFeaturesMaxLimitsGPUTest } from '../../gpu_test.js';
import { AllFeaturesMaxLimitsGPUTest, GPUTest } from '../../gpu_test.js';
import { reifyExtent3D } from '../../util/unions.js';

export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

Expand Down Expand Up @@ -90,6 +91,7 @@ const kTextureSubcases: readonly {
mipLevelCount?: number;
label?: string;
dimension?: GPUTextureDimension;
textureBindingViewDimension?: GPUTextureViewDimension;
sampleCount?: number;
invalid?: boolean;
}[] = [
Expand All @@ -115,18 +117,59 @@ const kTextureSubcases: readonly {
usage: GPUConst.TextureUsage.TEXTURE_BINDING,
mipLevelCount: 2,
},
{
size: [4, 4],
format: 'rgba8unorm',
usage: GPUConst.TextureUsage.TEXTURE_BINDING,
mipLevelCount: 2,
textureBindingViewDimension: '2d',
},
{
size: [4, 4],
format: 'rgba8unorm',
usage: GPUConst.TextureUsage.TEXTURE_BINDING,
mipLevelCount: 2,
textureBindingViewDimension: '2d-array',
},
{
size: [4, 4, 4],
format: 'rgba8unorm',
usage: GPUConst.TextureUsage.TEXTURE_BINDING,
mipLevelCount: 2,
},
{
size: [16, 16, 16],
format: 'rgba8unorm',
usage: GPUConst.TextureUsage.TEXTURE_BINDING,
dimension: '3d',
},
{
size: [16, 16, 16],
format: 'rgba8unorm',
usage: GPUConst.TextureUsage.TEXTURE_BINDING,
dimension: '3d',
textureBindingViewDimension: '3d',
},
{
size: [16, 16, 6],
format: 'rgba8unorm',
usage: GPUConst.TextureUsage.TEXTURE_BINDING,
dimension: '2d',
textureBindingViewDimension: 'cube',
},
{
size: [32],
format: 'rgba8unorm',
usage: GPUConst.TextureUsage.TEXTURE_BINDING,
dimension: '1d',
},
{
size: [32],
format: 'rgba8unorm',
usage: GPUConst.TextureUsage.TEXTURE_BINDING,
dimension: '1d',
textureBindingViewDimension: '1d',
},
{
size: { width: 4, height: 4 },
format: 'rgba8unorm',
Expand All @@ -142,6 +185,28 @@ const kTextureSubcases: readonly {
},
] as const;

function getExpectedTextureBindingViewDimension(
t: GPUTest,
descriptor: GPUTextureDescriptor
): GPUTextureViewDimension | undefined {
if (t.isCompatibility) {
if (descriptor.textureBindingViewDimension) {
return descriptor.textureBindingViewDimension;
}
switch (descriptor.dimension) {
case '1d':
return '1d';
case '2d':
case undefined:
return reifyExtent3D(descriptor.size).depthOrArrayLayers > 1 ? '2d-array' : '2d';
case '3d':
return '3d';
}
} else {
return undefined;
}
}

g.test('texture_reflection_attributes')
.desc(`For every texture attribute, the corresponding descriptor value is carried over.`)
.paramsSubcasesOnly(u => u.combine('descriptor', kTextureSubcases))
Expand Down Expand Up @@ -172,6 +237,10 @@ g.test('texture_reflection_attributes')
t.expect(texture.dimension === (descriptor.dimension || '2d'));
t.expect(texture.mipLevelCount === (descriptor.mipLevelCount || 1));
t.expect(texture.sampleCount === (descriptor.sampleCount || 1));
t.expect(
texture.textureBindingViewDimension ===
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aside: We should also have a separate (idl) test for 'textureBindingViewDimension' in GPUTexture.prototype. It's a really minor interoperability thing, but I think we do want all browsers to implement it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we? At the moment the only thing a core implementation needs to do is add the 4 new limits. They do not need to add this textureBindingViewDimension and have it be undefined. It's undefined by the fact that it doesn't exist. I feel like that's fine. I also feel like apple would push back. From their POV it would be a wart and things would arguably work without adding it. (vs the limits which were required)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to mark this as resolved of that's ok. If we decide the getter is required then we can add an idl test at that time.

getExpectedTextureBindingViewDimension(t, descriptor)
);
}, descriptor.invalid === true);
});

Expand Down